把Response.Redirect放到TryCatch中出的错误
来源:互联网 发布:网络层 编辑:程序博客网 时间:2024/05/16 05:53
把Response.Redirect放在Try Catch中会出现以下错误:
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
try
{
doSth();
Response.Rediret("a.html");
}
catch { }
{
doSth();
Response.Rediret("a.html");
}
catch { }
查了一下,原来是因为Response.Redirect会默认调用Respons.End(),而Respons.End方法会停止页的执行,并将该执行变换到应用程序的事件管线中的 Application_EndRequest 事件,所以Response.Redirect后面的代码(其实是Response.End后的代码)就不会执行了。
解决问题的办法是:调用Response.Redirect的重载函数Response.Redirect(String url, bool endResponse),参数为false。
如果try中有Response.End(),解决方法为:使用 ApplicationInstance.CompleteRequest 方法而不用Response.End,以避开Application_EndRequest 事件。
- 把Response.Redirect放到TryCatch中出的错误
- 把Response.Redirect放在Try Catch中会出现以下错误:
- 使用response Redirect时候出现的错误
- Response.Redirect的问题
- Response.Redirect的用法
- Response.Redirect 产生的“正在中止线程”错误
- Response.Redirect 产生的“正在中止线程(執行緒中止)”错误
- Response.Redirect 产生的“正在中止线程”错误
- ajax中使用Response.Redirect
- asp.net中Server.Transfer和Response.Redirect的区别
- 把CPropertySheet的标签放到下方时出现的错误
- 关于Response.Redirect的问题
- UpdatePanel中关于Response.Write、Response.Redirect和Server.Transfer的解决办法
- 把winform放到panel中
- 把pscp放到右键中
- 把进程放到ldt中
- 用objcopy把调试信息放到单独的文件中
- 震惊:把 URL 直接放到 C/C++ 的代码中
- 打字耍
- BCB 用友CELL 组件使用
- 表空间 用户 表
- 一卡通技术IC卡概述及分类
- 腾讯第一季度总收入25.04亿元 同比增长74.8%
- 把Response.Redirect放到TryCatch中出的错误
- 一位软件工程师的6年总结!~
- bochs工具用法以及常见问题小结
- vb
- JSF国际化
- 配置多个jsf文件
- ”操作必须使用一个可更新的查询“的解决
- linux 下p4perl安装install命令
- jsf 获取表单的两种方法