ASP.Net sending large attachment - blocks browsing until complete

0

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?

c#
asp.net
exception
iis
download
asked on Stack Overflow Sep 13, 2013 by steve cook • edited Sep 13, 2013 by steve cook

1 Answer

0

Looks like I've found the issue - with session state.

Setting <%@ EnableSessionState="ReadOnly" %> on the page seems to fix the problem.

answered on Stack Overflow Sep 13, 2013 by steve cook

User contributions licensed under CC BY-SA 3.0