views:

148

answers:

2

I have this code in the end of link button click:

Response.ContentType = "application/zip";
Response.AppendHeader("content-disposition", "attachment; filename=download.zip");
Response.TransmitFile(Server.MapPath("download.zip"));
Response.End();
Response.Flush();

to download a zip file from an aspx page.
In the previous page i set a session variable, after going to this download page and download the file, then press back i find the session=null "this happen after downloading more than 1 time", and the application_end in global.ascx called.

Do you know why this may happen??

Note: this is happening on all browsers, on IIS7 both local and on my server.

+1  A: 

Here is a really old article that may help you understand why the application is shutting down. http://aspalliance.com/902

JD
after using this code it told me : Website dir change or directory renameHostingEnvironment initiated shutdownHostingEnvironment caused shutdown
Amr ElGarhy
note that the download.zip file exist inside a subfolder not in the same folder as the download page.
Amr ElGarhy
A: 

I found my problem, my problem was in a previous line which was deleting a directory, and as you may know that deleting or renaming a folder inside the website folder will reset the application.

But JD answer helped me too much to trace and figure this problem.

Amr ElGarhy