Response.Redirect from Application_Error - session changes lost

  • Thread starter Thread starter Jon Paugh
  • Start date Start date
J

Jon Paugh

Hi,

So in Application_Error method in Global class of my
ASP.NET web project, I add:

HttpContext.Current.Session["SomeSessionThing"]
= "SomeSessionThing";

Then, in Application_Error method I Response.Redirect to
a error page. In the page's load, I check the value of

HttpContext.Current.Session["SomeSessionThing"]

and it now returns null.

What is going on here? I thought session would always be
preserved no matter what? I am using out of proc session
option.

Thanks,

Jon
 
Ok, I get to answer my own question. Are you ready? The
super secret technique for persisting session in
Application_Error,:

just call

Server.ClearError();
 
Back
Top