views:

32

answers:

1

Whenever I use TransmitFile to send a file, the sirte becomes blocked to the user until the file completes. IOW, the user cannot navigate the site.

If the user cancels the transfer, it still blocks until the site either times out OR finishes sending the data. I can't tell which, but I know if for example I cancel a 30MB file immediately after starting the download, it takes longer to recover than a 10 MB file.

Here is the relevant code:

Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", contdisp);
Response.AddHeader("Content-Length", new FileInfo(fullfilename).Length.ToString());
Response.TransmitFile(fullfilename);
Response.Flush();
A: 

Figured this out and I better post it in case I get the problem again or someone else has this issue.

The problem is caused by the fact that my page uses session data. My download page needs this session data to remember certain things like sort, search terms, etc. I should note that the page also displays the files and runs the code above on clicking a button.

Because of this, when my download code (snippet above) runs, the transfer is protected by IIS to insure the session data remains intact. This is as it should be under normal page navigation but obviously unwanted for a file transfer.

By moving the download code out of this page and into one that has no session data the download can happen while the user happily continues to navigate the site.

I also made the new download page with the EnableSessionState="False" in the Page directive to insure it would not use the session.

NFX