Session varaibles are lost when an error occurs

S

So

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.
 
M

Mircea Pleteriu

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.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top