title: How to force download of file from ASP.NET WebAPI
body: <p>This is my web-api code:</p>
  
  <pre><code>    [HttpPost]
      public HttpResponseMessage PostFileAsAttachment()
      {
          string path = "D:\\heroAccent.png";
          if (File.Exists(path))
          {
  
              HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
              var stream = new FileStream(path, FileMode.Open);
              result.Content = new StreamContent(stream);
              result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
              result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
              result.Content.Headers.ContentDisposition.FileName = "xx.png";
              return result;
          }
          return new HttpResponseMessage(HttpStatusCode.NotFound);
      }
  </code></pre>
  
  <p>And how to Code the Client side(view) to force a download file to me(like auto download mode(open、save as) can pop up...)</p>