title: How to transmit/receive raw byte array using ASP.NET Core Web API?
body: <p>I've written my first ASP.NET Core Web API server. The routing is working and it is sending/receiving. I'd like to send a raw Byte array in response to a Get and I'd like to bypass any serialization (as well as any deserialization in my WPF client). For example, in my server:</p>
  
  <pre><code>[HttpGet("api/data")]
  public Byte[] GetData()
  {
      Byte[] data = new Byte[]{1, 2, 3, 4, 5};
      return data; // No JSON, BSON or anything else...just my array. Is it done this way?
  }
  </code></pre>
  
  <p>In my WPF client I'd like to use the HttpClient class to receive the array - no deserialization required:</p>
  
  <pre><code>// Assume an instantiated and initialized HttpClient object called "httpCLient"
  HttpResponseMessage response = httpClient.GetAsync("/api/data").Result;
  // Now what?
  </code></pre>
  
  <p>I've scoured the internet but I haven't found an example of this, and I've been unable to figure out on my own. Could somebody please show me how this is done?</p>
  
  <p>Update: I believe the client-side <code>Byte[]</code> retrieval can be accomplished via "HttpContent.ReadAsByteArrayAsync()" as shown here: <a href="https://stackoverflow.com/questions/31147279/convert-httpcontent-into-byte">Convert HttpContent into byte[]</a>. I still am unsure as to how to send the raw (unserialized) <code>Byte[]</code> from the ASP.NET Core Web API side however.</p>