If you are a .net developer then you can hardly avoid using one of the above methods of Response object.In my case I was using Response.Redirect and Response.End as under
Once the code went live , we were getting loads of errors in the event viewer .After spending some time doing google with bing(as Scott Hanselman says ) and doing some reading this is what I found .
“If you use the Response.End, Response.Redirect, or Server.Transfer method, a ThreadAbortException exception occurs.”
So here are the list of viable options you could use to either recover or avoid this from happening
Option1 : For Response.End ,call the HttpContext.Current.ApplicationInstance.CompleteRequest method
Option 2: For response.Redirect,use an overload,Response.Redirect(string url,bool endResponse)that passes false for the endResponse parameter to suppress the internal call to Response.End .
NB :If you use this workaround ,the code that follows Response,Redirect is executed
Option3:For Server.Transfer,use Server.Execute method instead
Option 4:Use multiple try catch block as under
Catch threadAbortExc As Threading.ThreadAbortException
‘You logic to handle thread abort exception here
Catch ex As Exception
‘Your logic to handle all other generic exceptions here
‘You logic for finally block here
Hope this saves trouble for some of you guys out there .
References and further readings: