title: Mvc4 webapi file download with jquery
body: <p>I want to download file on client side from api<br>
    apicontroller:</p>
  
  <pre><code>     public HttpResponseMessage PostOfficeSupplies()
       {
          string csv = string.Format ("D:\\Others\\Images/file.png");
          HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
          result.Content = new StringContent(csv);
          result.Content.Headers.ContentType = new MediaTypeHeaderValue     ("application/octet-stream");
  
          result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
          result.Content.Headers.ContentDisposition.FileName = "file.png";
          return result;    
      }
  </code></pre>
  
  <p>1.How can I popup a download with jquery(octet-stream) from api controller?</p>
  
  <pre><code>     my client side code:
       $(document).ready(function () {
              $.ajax(
              {
                  url: 'api/MyAPI'
              , type: "post"
              , contentType: "application/octet-stream"
              , data: ''
              , success:
              function (retData) {
                  $("body").append("&lt;iframe src='" + retData + "' style='display: none;' &gt;&lt;/iframe&gt;");
                                 }
  
              });
  
  
  });
  </code></pre>
  
  <p>but it was not work!</p>