title: Accept and download stream content from ASP.NET Web API using HTTPClient
body: <p>I have an ASP.NET Web API action which creates a file and returns a stream content:</p>
  
  <pre><code>public HttpResponseMessage Get(string filePath)
  {
      // create file
      var file = FileConverter.GenerateExcelFile(filePath);
  
      var stream = new FileStream(filePath, FileMode.Open);
  
      HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
      result.Content = new StreamContent(stream);
      result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
      result.Content.Headers.ContentDisposition.FileName = Path.GetFileName(filePath);
      result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
      return result;
  }
  </code></pre>
  
  <p>I would like to use HttpClient to download the returned file. Here's what I have now:</p>
  
  <pre><code>    client.GetAsync(address).ContinueWith(
          (requestTask) =&gt;
          {
               HttpResponseMessage response = requestTask.Result;
  
              // response.EnsureSuccessStatusCode();
  
              response.Content.ReadAsStreamAsync().ContinueWith(
                          (readTask) =&gt;
                          { 
                              var stream = readTask.Result; 
                          });
          });
  </code></pre>
  
  <p>How do I force the actual download after getting the result?</p>
  
  <p>Edit: I'm  using ASP.NET 4.0 WebForms.</p>