Response is not available in this context - page blowing

R

rao

Hi

I am generating unique xml files and deleting them in page_unload event.
Application responds properly in normal conditions. When I keep clicking
on url that invoke the page several times the application blow up with
following error "Response is not available in this context". This happens
only when I keep clicking on link for stress test. Here is the code I process
on page_unload event. Any suggestions are welcome.


Thanks
Rao


private void Page_UnLoad(object sender, System.EventArgs e)
{
try
{
if (File.Exists(Server.MapPath(xmlDocPath+ProjectsDoc)))
{
File.Delete(Server.MapPath(xmlDocPath+ProjectsDoc));
}
if (File.Exists(Server.MapPath(xmlDocPath+ResourcesDoc)))
{
File.Delete(Server.MapPath(xmlDocPath+ResourcesDoc));
}
}
catch(Exception ex)
{Response.Write(ex.Message.ToString());}
}
 
K

Karl

The error message is pretty clear, Response isn't available in the context.
In other words, you can use Response.Write in the Page_Unload event. The
only relation that this has to your fast clicking is that it's causing an
exception to be thrown.

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top