title: Download selected files in knockout js
body: <p>I need to download the selected files in a grid on download button click. I am using knokout.js and web api 
  Using the below given response I was able to download a single file </p>
  
  <pre><code> self.DownloadDoc = function () {
      window.location.assign("http://localhost:8092/api/Document/GetResponse?id=" + self.selectedDocuments()[0]);
      self.selectedDocuments.removeAll();
      self.bindDocuments();
  }; 
  </code></pre>
  
  <p>I tried looping this window.location.assign() code using for loop,but as it is synchronous call,its downloading only one file.</p>
  
  <p><strong>Html part</strong></p>
  
  <pre><code>&lt;a href="#" data-bind="click :$root.DownloadDoc,visible: $root.DownloadDocVisible"&gt;&lt;span&gt;Download&lt;/span&gt;&lt;small&gt;&lt;/small&gt;&lt;/a&gt;
  </code></pre>
  
  <p><strong>Web Api code</strong></p>
  
  <pre><code> [HttpGet]
      public HttpResponseMessage GetResponse(string id)
      {
          HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
          List&lt;DocumentsModel&gt; documents = _service.GetDocumentContent(Convert.ToInt32(id));
          byte[] fileBytes = documents.FirstOrDefault().FileContent;
  
  
          System.Net.Http.Headers.MediaTypeHeaderValue mediaType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
          if (fileBytes != null)
              response.Content = new ByteArrayContent(fileBytes);
  
          response.Content.Headers.ContentType = mediaType;
          response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
          response.Content.Headers.ContentDisposition.FileName = documents.FirstOrDefault().FileLeafRef;
  
          return response;
      }
  </code></pre>