Try
{
...
.. Response.Redirect ("/mymaimai.aspx"); ..
}
catch (Exception e)
{
//exception handling
}
Using the above statement, regardless of whether there is an exception, the catch will be executed, always show "" failed ", will throw System.Threading.ThreadAbortException, for the following reasons:
The Response.End method stops the execution of the page and transforms the execution to the Application_EndRequest event in the application's event pipeline. The code line following the Response.End is not executed.
This problem occurs in the Response.Redirect and Server.Transfer methods because both of these methods call Response.End internally.
Solution
To resolve this issue, use one of the following methods:
For Response.End, call the Applicationinstance.completerequest method without invoking the Response.End so that the code execution of the Application_EndRequest event is skipped.
For Response.Redirect, use the overloaded Response.Redirect (String URL, bool endresponse) to pass false to the Endresponse parameter to cancel the inside of the Response.End Call. For example:
Response.Redirect ("/mymaimai.aspx", false); If you use this workaround, the code behind Response.Redirect will be executed.
For Server.Transfer, use the Server.Execute method instead.
State
This phenomenon is the result of design.
Resolved code:
Try
{
Response.Redirect ("/mymaimai.aspx", false);
}
Catch
{
//exception handling
}