保存后进行跳转
程序执行到重定向语句比如 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 方法。