Session ending without any warning!

A

Arti

Hi everybody,

I am using ASP.NET 2.0.

When redirecting from page1 to page2 using Response.Redirect() method
ThreadAbortException is raised.

In my condition sometimes even though this exception is caught and handled
by my code, the session_end method in global.asax is getting called, which
implies that all my sessions are ended and hence i am forced to login once
again!

Can somebody please let me know what i am missing here, any solution to
avoid this error...

Thanks and Regards.
 
M

Mark Rae [MVP]

When redirecting from page1 to page2 using Response.Redirect() method
ThreadAbortException is raised.

In my condition sometimes even though this exception is caught and handled
by my code, the session_end method in global.asax is getting called, which
implies that all my sessions are ended and hence i am forced to login once
again!

Can somebody please let me know what i am missing here, any solution to
avoid this error...

The Response.Redirect method has an overload whereby you tell it not to
abort the thread:
http://msdn2.microsoft.com/en-us/library/a8wa7sdt(VS.80).aspx

I'm not convinced that this will solve the problem, though, because it
certainly shouldn't be tearing down your session...

Worth a try in the first instance, though...
 
B

Bjorn Sagbakken

Arti said:
Hi everybody,

I am using ASP.NET 2.0.

When redirecting from page1 to page2 using Response.Redirect() method
ThreadAbortException is raised.

In my condition sometimes even though this exception is caught and handled
by my code, the session_end method in global.asax is getting called, which
implies that all my sessions are ended and hence i am forced to login once
again!

Can somebody please let me know what i am missing here, any solution to
avoid this error...

I'm not sure this is the same I have seen, but if you redirect to another
page while the first page still has an open database connection, this may be
the result. So make sure everything is cleaned up before redirecting to
another page. Then you will not get that exception at all.

Bjorn
 
A

Arti

Thanks Mark, I tried that one out but it doesn't work... :(

Hi Bjorn,
The problem is that this problem occurs only in certain conditions... Do you
still think this solution will solve the problem?

Regards
Arti.
 
B

Bjorn Sagbakken

Arti said:
Thanks Mark, I tried that one out but it doesn't work... :(

Hi Bjorn,
The problem is that this problem occurs only in certain conditions... Do
you still think this solution will solve the problem?

I don't know, depends on the details in your conditions. Let's say you
retrieve database records, and sometimes you encounter unexpected values
like dbNull where there is supposed to be a number. If this situation isn't
taken into the code, you may get an exeption that escapes the open thread.
There are all sort of possibilities in this direction, but since I don't
know anything about the app or the conditions when this happens, I am only
guessing.

Bjorn
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top