zoukankan      html  css  js  c++  java
  • 关于Response.End的亦常

    异常:由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值

    原因:

    如果使用 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);

  • 相关阅读:
    eclipse使用svn
    yum安装mysql
    spring中aop使用
    mybatis定义拦截器
    横扫页面的三大标签
    springmvc日期格式化
    springmvc笔记
    springboot跳转jsp页面
    常用网址
    CentOS Android Studio桌面图标的创建
  • 原文地址:https://www.cnblogs.com/zhangji/p/2051957.html
Copyright © 2011-2022 走看看