I'm running the following code in ASP.Net on IIS:
try
{
Response.Clear();
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment;filename=MyBigFile.zip");
Response.TransmitFile(Server.MapPath("~/Stuff/MyBigFile.zip"));
Response.Flush();
}
catch (Exception ex)
{
Logger.Error("File download failed", ex);
}
The problem is that the user cannot navigate to any other page on my website until the download is completed (I found this because it looks like users are manually cancelling the download because it often throws the exception The remote host closed the connection. The error code is 0x800703E3.
)
How can I get the download to spawn in the background, and allow my users to keep browsing the site while they are downloading?
Looks like I've found the issue - with session state.
Setting <%@ EnableSessionState="ReadOnly" %>
on the page seems to fix the problem.
User contributions licensed under CC BY-SA 3.0