In our project we have got a admin application and a client application. The admin application is used to manage all clients.
So when i logged in to server application , the admin credentials are saved in session.
After that i accessed client application in another browser. It contains a download functionality. After download what happens is that it clears all session data. So after each download i need to login again in the admin module.
Download handler
if (context.Request["fileUrl"] != null)
{
fileUrl = context.Request["fileUrl"].ToString();
}
string filename = System.IO.Path.GetFileName(fileUrl);
context.Response.ClearContent();
context.Response.ContentType = "application/exe";
context.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", filename));
context.Response.TransmitFile(fileUrl);
context.Response.Flush();
I have used an iframe to do the download. So i will set the source for iframe when download button is clicked
Code behind file
iframeDownload.Attributes["src"] = "DownloadHandler.ashx?fileUrl=" + downloadUrl;
//code to be executed after download
//here i am enabling a timer control
But i can't find why the session is cleared after this download. I found a similar issue in this SO post. Session expires after file download
But for him it happens only in IE, but in my case its happening in all browsers.