"Aborting thread" error generated by Response.Redirect
Today during development debugging, a "aborting thread" exception message appears. Call Response.Redirect () method produced, although know is the problem of the thread, but I do not know why Redirect will appear such a mistake, was not encountered before, in the mad baidu,google a bit, only to find that Ms Long solved the problem, But it provides a workaround. Abnormal
If you use the Response.End, Response.Redirect, or Server.Transfer methods, a ThreadAbortException exception occurs. You can use the Try-catch statement to catch this exception.
Reason
The Response.End method terminates the execution of the page and switches this execution to the Application_EndRequest event in the application's event pipeline. The line of code that follows Response.End is not executed. This problem occurs in the Response.Redirect and Server.Transfer methods, because both methods call Response.End internally.
Solution Solutions
To resolve this issue, use one of the following two methods: for Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End method to skip code execution for the Application_EndRequest event.
For Response.Redirect, use the overloaded Response.Redirect (String URL, bool endresponse) method, which passes false to the Endresponse parameter to cancel the Internal invocation of the Response.End. For example: Response.Redirect ("microscopelist.aspx", false);
Take note of this error, the traces of the steps forward
"Aborting thread" error generated by Response.Redirect