title: Web Api 2 not returning ByteArrayContent to HTTPClient
body: <p>I am putting together a test application using WebApi2 and HttpClient in a win forms app.</p>
  
  <p>I have come accross an issue where my HttpClient request to a WebApi2 controller which returns an HttpResponseMessage doesnt return the ByteArrayContent.
  WebApiController Code</p>
  
  <pre><code>[HttpGet]
  public HttpResponseMessage DownloadFilePart(string fileName)
  {
      var path = Server.MapPath("~/App_Data/uploads/" + fileName);
      var fileArray = System.IO.File.ReadAllBytes(path);
  
      var response = new HttpResponseMessage(HttpStatusCode.OK)
      {
          Content = new  ByteArrayContent(fileArray)
      };
  
      response.Content.Headers.ContentType = new MediaTypeHeaderValue(System.Web.MimeMapping.GetMimeMapping(fileName));
      response.Content.Headers.ContentLength = fileArray.Length;
      response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
      {
          FileName = fileName
      };
  
      return response;
  }
  </code></pre>
  
  <p>WinForms Code using HttpClient</p>
  
  <pre><code>static async void GetFilePart(string hostrUri)
  {
      var httpClient = new HttpClient
      {
          BaseAddress = new Uri(hostrUri)
      };
  
      var request = new HttpRequestMessage(HttpMethod.Get, "/Home/DownloadFilePart/?fileName=Test.txt");
      var responseMessage = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
      var memoryStream = new MemoryStream();
      var stream = await responseMessage.Result.Content.ReadAsByteArrayAsync();
      var fileToWriteTo = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\Temp\\Test.txt";
  
      using (var fileStream = new FileStream(fileToWriteTo, FileMode.Create, FileAccess.Write, FileShare.None))
      {
          //copy the content from response to filestream
          fileStream.Write(stream, 0, stream.Length);
      }
  }
  </code></pre>
  
  <p>When the request return from the WebApi and I write the bytes to file all that is written into the file is the actual headers from the WebApi response. Has anyone any ideas what the issue could be here?</p>
  
  <p>Thanks</p>