保存后进行跳转

程序执行到重定向语句比如 Redirect(..)时,catch(..)块会捕获一个异常,"线程正被中止。"(System.Threading.ThreadAbortException)。
捕捉异常后,页面还是进行了跳转.

在网上找到2篇文章参考

http://blog.csdn.net/xuandhu/archive/2004/11/17/184726.aspx

http://www.cnblogs.com/loulanlouzhu/archive/2004/04/19/6494.html

原因:
Response.End 方法停止页的执行,并将该执行变换到应用程序的事件管线中的 Application_EndRequest 事件。 Response.End 后面的代码行将不执行。


解决:
  • 对于 Response.End,调用 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 方法。


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-06-26
  • 2022-12-23
猜你喜欢
  • 2022-02-12
  • 2021-11-30
  • 2021-07-17
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案