zoukankan      html  css  js  c++  java
  • Response.Redirect出现Unable to evaluate expression because the code is optimized or a native frame……异常解决方法

    SYMPTOMS(症状)
        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(解决)
        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);   //此种方法比较简单。

        If you use this workaround, the code that follows Response.Redirect is executed.
        •For Server.Transfer, use the Server.Execute method instead.


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

  • 相关阅读:
    第三次作业
    第二次作业
    10.30 非确定的自动机NFA确定化为DFA
    10.23 正规式、正规文法与自动机
    10.16 正规文法与正规式
    10.9 词法分析程序的设计与实现
    9.25 文法和语言总结与梳理
    9.18 语法树,短语,直接短语,句柄
    9.11 理解文法和语言
    9.4 了解编译原理
  • 原文地址:https://www.cnblogs.com/scottckt/p/2278258.html
Copyright © 2011-2022 走看看