Error - mscorlib : Thread was being aborted.

G

Guest

I had the following code inside my app
try
{
// Open an ADO.NET db connection
// Do some db processing here

Response.Redirect("main.htm");
}
catch(Exception e)
{
}

The Response.Redirect("main.htm") state was generating the error 'mscorlib
: Thread was being aborted'. But when I took that statement out of the
try..catch block it ran fine. Why does Ressponse.Redirect cause an error
inside a try..catch statement?

Thanks in advance
 
G

Guest

Clarification: Actually its just the try{} block, runs fine in the
catch(Exceptione) {} block
 
B

Brock Allen

A ThreadAbortException is thrown when Redirect is used - it's just how it
works. Why are you doing a catch(Exception e)? If your code can't "handle"
every exception, then I'd suggest not having the catch block there. If there's
a specific exception you know how to deal with, then use the catch (like
FormatException or SqlException for example). To be notified that there was
an unhandled exception (one you didn't catch) you should put a Application_Error
handler in global.asax; this is where your error logging should go.

-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