zoukankan      html  css  js  c++  java
  • ASP.NET "正在中止线程"错误原因及解决方法【转】

    ASP.NET "正在中止线程"错误原因,assignment、call、increment、decrement 和 new 对象表达式可

    错误 1 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
    解决办法:方法的调用按照C#的语法必须在其后面加()
    在使用 Response.End、Response.Redirect 或 Server.Transfer 时出现 ThreadAbortException
    症状如果使用 Response.End、Response.Redirect 或 Server.Transfer 方法,将出现 ThreadAbortException 异常。您可以使用 try-catch 语句捕获此异常。
    原因Response.End 方法终止页的执行,并将此执行切换到应用程序的事件管线中的 Application_EndRequest 事件。不执行 Response.End 后面的代码行。

    此问题出现在 Response.Redirect 和 Server.Transfer 方法中,因为这两种方法均在内部调用 Response.End。
    解决方案要解决此问题,请使用下列方法之一:
    •        对于 Response.End,调用 HttpContext.Current.ApplicationInstance.CompleteRequest 方法而不是 Response.End 以跳过 Application_EndRequest 事件的代码执行。
    •        对于 Response.Redirect,请使用重载 Response.Redirect(String url, bool endResponse),该重载对 endResponse 参数传递 false 以取消对 Response.End 的内部调用。例如: Response.Redirect ("nextpage.aspx", false);如果使用此替代方法,将执行 Response.Redirect 后面的代码。
    •        对于 Server.Transfer,请改用 Server.Execute 方法。
  • 相关阅读:
    Spring AOP原理
    Spring Boot引入Oracle Jar
    Cookie
    资源验证
    HTTP各种特性
    高性能网络编程之IO和NIO阻塞分析
    Http协议基础及发展历史
    Http原理与实践
    设计模式-回顾
    http://jingyan.baidu.com/article/fcb5aff78e6a48edab4a7146.html
  • 原文地址:https://www.cnblogs.com/Godblessyou/p/1779655.html
Copyright © 2011-2022 走看看