Professional Programmer Notes

or just call this my soapbox

Handling mscorlib.dll System.Threading.ThreadAbortException issue in an ASP.NET application

leave a comment »

I discovered an unhandled System.Threading.ThreadAbortException was being thrown in my ASP.NET application. I was only able to see this issue when running the application in the Visual Studio debugger. The offending code was a seemingly trivial call to Response.Redirect.

When I called Response.Redirect, the thread handling the current response would be aborted. The thread didn’t like being aborted out of the blue like that. The fix is to pass the second parameter to the Response.Redirect method which tells Response.Redirect whether or not it should end the response. Passing in false will cause the Redirect method to fire, but allow the original response thread to execute the code after the call to Response.Redirect. I use a Return statement to avoid unnecessary processing.

Microsoft explains it here: http://support.microsoft.com/default.aspx?scid=kb;en-us;312629

Advertisements

Written by curtismitchell

April 8, 2009 at 9:20 am

Posted in .net

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: