Monday, July 7, 2014

Catch ThreadAbortException in ASP.Net

In ASP.Net, whenever a redirect or response end statement is executed, ThreadAbortException is thrown and it is logged in event viewer.

System.Threading.ThreadAbortException Message: Thread was being aborted. 
Source: mscorlib at System.Threading.Thread.AbortInternal() 
at System.Threading.Thread.Abort(Object stateInfo) 
at System.Web.HttpResponse.End() 

To avoid thread ThreadAbortException related messages in logging, call to Response.Redirect and Response.End methods should be wrapped in try-catch block. Simply catching this exception will not work as the exception is thrown again even after getting caught. So, in the catch block a call should be made to Thread.ResetAbort() method.

catch(ThreadAbortException ex)
    //Exception is again thrown after catch block.
    //To suppress it call ResetAbort method of System.Threading.Thread

1 comment:

  1. Staffing is way and away the biggest expense for a small charity like 온라인 카지노 ours and we glance to maintain the variety of individuals employed low to ensure that|to make sure that} funding remains out there to make necessary enchancment. We’ve run some exams to see what influence BetBlocker may have on how lengthy you can to|you presumably can} count on your battery to final while the app is lively. Please thoughts that|remember that|understand that} these are very general exams to give an idea of the influence. Your experience might differ relying on other apps you could have} working in your phone, the make and model of your phone and the size of your battery. We aren't utilizing a keyword blocker however have put collectively a list of some hundred of the pornography sites that happen most incessantly on the primary page of Google for {some of the|a few of the|a variety of the} highest quantity search phrases. The various to generating such a list would be to make use of a keyword blocker – this would to|this may} block any page that accommodates particular keywords which might be} generally used on pornographic websites.