title: Download file asynchronous C# MVC
body: <p>I have created a controller that, through a stream, lets the user download a CSV-file, but when it's downloading, the user can't do anything else on the site.</p>
  
  <p>The controller is:</p>
  
  <pre><code>public async Task ExportClientsListToCSV(string guid)
  {
      var search = Session[guid] as SearchVM;
  
      StringWriter sw = new StringWriter();
      sw.WriteLine("\"Name\",\"Status\",\"E-mail\",\"Phone\"");
  
      Response.ClearContent();
      Response.AddHeader("content-disposition", "attachment;filename=Exported_Organizations.csv");
      Response.ContentType = "text/csv";
      Response.ContentEncoding = Encoding.UTF32;
  
      var result = await _adminFacade.OrganizationAllSearchAsync(search.SearchQuery,
                      false,
                      false);
  
      foreach (var line in result)
      {
          sw.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\"", 
              line.OrganizationName, line.Status, line.OrgContactEmail, line.Phone);
          }
  
      Response.Write(sw.ToString());
  
      Response.End();
  }
  </code></pre>
  
  <p>Right now I solve it by <code>Html.ActionLink("Export", "ExportClientsListToCSV", new {guid = Model.DownloadGuid})</code> but I've also tried with:</p>
  
  <pre><code>e.preventDefault();
  $.ajax({
      cache: false,
      url: this.exportUrl,
      data: this.$form.serialize()
  })
  .success(function(data) {
      window.open(this.downloadUrl + '?guid=' + data.fileGuid, '_blank');
  }.bind(this));
  </code></pre>
  
  <p>Which sure opened in a new window/tab, but the user couldn't do anything in the original tab until the file actually was downloaded. Is there anyway to work around this?</p>