How can I detect when a file download has completed in ASP.NET?
Posted
by
Alexis
on Stack Overflow
See other posts from Stack Overflow
or by Alexis
Published on 2011-01-13T02:14:29Z
Indexed on
2011/01/13
5:54 UTC
Read the original article
Hit count: 321
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.
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();
© Stack Overflow or respective owner