Thursday, March 29, 2012

Session varaibles are lost when an error occurs

In VS2003, when debugging (with breakpoints set) a ASP.net web project
(locally), if an error/exception occurs the browser navigates to the "Server
Error" page. After this point it looses all the values stored in the Session
objects, and leads to many other errors, before I must refresh the page and
restart all over again. What the problem can be?

Thanks in advance.Hi,

Before redirecting to the error page the current session is distroyed and a
new session is created. This is the ASP.NET behavior. What you can do is to
catch all unhandled exceptions in the Application_Error from Global file. In
this handler you should clean the error and manually redirect to your custom
error page using Server.Transfer method. This way you prevent the
application from distroying the session.

"So" <.> wrote in message news:O38eKVIUFHA.2712@.TK2MSFTNGP09.phx.gbl...
> In VS2003, when debugging (with breakpoints set) a ASP.net web project
> (locally), if an error/exception occurs the browser navigates to the
"Server
> Error" page. After this point it looses all the values stored in the
Session
> objects, and leads to many other errors, before I must refresh the page
and
> restart all over again. What the problem can be?
> Thanks in advance.

0 comments:

Post a Comment