title: How can I detect when a file download has completed in ASP.NET?
body: <p>I have a popup window that displays "Please wait while your file is being downloaded".  This popup also executes the code below to start the file download.  How can I close the popup window once the file download has completed?  I need some way to detect that the file download has completed so I can call self.close() to close this popup.</p>
  
  <pre><code>System.Web.HttpContext.Current.Response.ClearContent();
  System.Web.HttpContext.Current.Response.Clear();
  System.Web.HttpContext.Current.Response.ClearHeaders();
  System.Web.HttpContext.Current.Response.ContentType = fileObject.ContentType;
  System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", string.Concat("attachment; filename=", fileObject.FileName));
  System.Web.HttpContext.Current.Response.WriteFile(fileObject.FilePath);
  Response.Flush();
  Response.End();
  </code></pre>