Try
{
...
Response. Redirect ("/Mymaimai. aspx");...
}
Catch (exception E)
{
//Exception Handling
}
Use the preceding statement , Whether or not exceptions exist , All Catch In , Always show "" Failed "" Will throw system. Threading. threadabortexception, The reason is as follows: :
response. end the method stops page execution, convert the execution to application_endrequest event. response. end Code lines following the "> will not be executed.
This problem occurs inResponse. RedirectAndServer. TransferMethod, because both methods are called internallyResponse. End.
Solution
to solve this problem, use one of the following methods:
for response. end , call applicationinstance. completerequest method without calling response. end , to skip applicatio N_endrequest Event code execution.
For Response. Redirect , Use overload Response. Redirect (string URL, bool endresponse) Endresponse It is passed False To cancel Response. End . For example:
Response. Redirect ("/Mymaimai. aspx", False );If you use this solution,Response. RedirectThe subsequent code will be executed.
ForServer. Transfer, UseServer. ExecuteMethod.
Status
This phenomenon is caused by design.
Code after solution :
Try
{
Response. Redirect ("/Mymaimai. aspx" , False );
}
Catch
{
//Exception Handling
}