Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my asp.net application throwing ThreadAbortException?

This is a self-explanatory question:

Why does this thing bubble into my try catch's even when nothing is wrong?

Why is it showing up in my log, hundreds of times?

I know its a newb question, but if this site is gonna get search ranking and draw in newbs we have to ask them

like image 885
DevelopingChris Avatar asked Aug 15 '08 17:08

DevelopingChris


People also ask

What causes system threading ThreadAbortException?

When a call is made to the Abort method to destroy a thread, the common language runtime throws a ThreadAbortException on . NET Framework. ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block.

Which method is used to terminate the thread and rise ThreadAbortException?

Abort() Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread.


Video Answer


3 Answers

This is probably coming from a Response.Redirect call. Check this link for an explanation:

http://dotnet.org.za/armand/archive/2004/11/16/7088.aspx

(In most cases, calling Response.Redirect(url, false) fixes the problem)

like image 185
Eric Z Beard Avatar answered Oct 17 '22 11:10

Eric Z Beard


The most common reason for a ThreadAbortException is calling Response.End, Response.Redirect, or Server.Transfer. Microsoft has published some suggested functions that should be used in stead of those functions.

like image 7
rjzii Avatar answered Oct 17 '22 11:10

rjzii


As others have said, it occurs when you call Response.End() (which occurs when you call Response.Redirect without passing false as the second parameter). This is working as designed; typically, if you call Response.Redirect, you want the redirect to happen immediately. See this for more information:

Response.Redirect and the ThreadAbortException

like image 1
Jon Sagara Avatar answered Oct 17 '22 11:10

Jon Sagara