Response. Redirect appears unable to evaluate expression because the code is optimized or a native frame ...... Exception

Source: Internet
Author: User
Symptoms (symptom)
If you use the response. End, response. Redirect, or server. transfer method, a threadabortexception exception occurs. You can use a try-catch statement to catch this exception.

Cause)

The response. End method ends the page execution and shifts the 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.

Resolution (solution)
To work around this problem, use one of the following methods:
• For response. End, call the httpcontext. Current. applicationinstance. completerequest method instead of response. End to bypass the code execution to the application_endrequest event.
• 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. For example:
Response. Redirect ("nextpage. aspx", false );// This method is relatively simple.

 

If you use this workaround, the code that follows response. Redirect is executed.
Server. Transfer, UseServer. ExecuteMethod instead.

 

Self: http://hi.baidu.com/richard_cxs/blog/item/18024859d365ba2b2834f017.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.