I am using Server.Transfer. Everything works fine, but exception log shows following exception.
System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) at System.Web.HttpServerUtility.Transfer(String path)
Any idea to avoid above exception.
When a call is made to the Abort method to destroy a thread, the common language runtime throws a ThreadAbortException . ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block.
Abort(Object) Obsolete. Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread while also providing exception information about the thread termination. Calling this method usually terminates the thread.
This exception is throw by the call to Server.Transfer
in order to halt the execution of the current method - exactly the same thing gets thrown if you do Response.Redirect
.
The two choices you have are:
Server.Transfer
Server.Transfer
in places where it wont be caught (recommended)EDIT: Scratch that, http://support.microsoft.com/kb/312629 has a couple of other suggestions to try, but I still recommend #2 above.
Another way to solve this, is to catch the generated error and to not rethrow it:
catch (ThreadAbortException) { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With