ThreadAbort on redirect?

G

Guest

Hello,

I have a simple redirect on a login page:

Login_Click()
{
// ... do the login verification
try {
Response.Redirect("index.aspx");
}
catch(Exception ex) {
// Get ThreadAbortException here!
}
}

When I catch the ThreadAbortException, the redirect fails to work, and I am
left back on the login page. Subsequent attempts also result in
ThreadAbortException.

I am wondering if this would happen when the aspnet_wp process recycles the
application instance? Is there anything that can be done to recover from the
ThreadAbortException being raised?? Maybe the Server.Transfer() would be
more reliable in ASP.NET??

Thanks

-- Jake
 
B

Brock Allen

The ThreadAbortException is a little trick that ASP.NET uses to do the Response.Redirect
(actually, it's how it does Response.End()). This does work, as long as in
your catch blocks you're not affecting what the Redirect was doing. Also,
if you're running in the debugger and you have it set to break on all exceptions
then you won't see what you're expecting. From VS.NET, to run you page use
Ctrl-F5, not F5.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 

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

Top