title: ASP.net dowload/export without using HttpContext
body: <p>I know there are a lot of questions about downloading and exporting files from an asp.net website, but they all end up with the same answer.  My website gives users the option to download files and export data to an excel spreadsheet.  Currently, I am using the solution everyone seems to provide which looks like this:</p>
  
  <pre><code>public void ExcelExport(System.Data.DataTable dtData, String strFileName)
  {
      try
      {
          HttpContext.Current.Response.Clear();
          HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
          HttpContext.Current.Response.ContentType = GetMIMEType(Path.GetExtension(strFileName));
  
          HttpContext.Current.Response.Write(BuildStringWriter(dtData));
          HttpContext.Current.Response.Flush();
          HttpContext.Current.Response.Close();
      }
      catch (Exception ex)
      {
          throw new Exception("ExcelExport() Failed: " + ex.Message);
      }
  }
  </code></pre>
  
  <p>This is the method I call to export data, and my download method is almost identical.  The problem is that it I cannot show a spinner or waiting message because I have no way of closing either one once the export/download is completed. There are also other tasks I would like to execute after exporting/downloading, but I currently cannot.</p>
  
  <p>So, my question is: is there another means for my client's to download files and export data without using HttpContext?  Also, I would prefer not having reference a dll that I would have to download.</p>
  
  <p>Thanks</p>