asp.net的Server.Transfer()异常 [英] asp.net Server.Transfer() exception

查看:116
本文介绍了asp.net的Server.Transfer()异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我收到异常当执行Server.Transfer的()...

  Server.Transfer的(@?〜/学生/ StudentSendMail.aspx用户名=+用户名);{无法评估前pression因为code优化或本机框上调用堆栈的顶部。}


解决方案

这奇怪的错误消息的一个原因是try-catch块内执行Server.Transfer的。有一对夫妇的方式来处理:

1)添加第二个参数设置为false这样的:

  Server.Transfer的(@?〜/学生/ StudentSendMail.aspx用户名=+用户名,假的);

2)捕捉类型的异常 System.Threading.ThreadAbortException 键,所以异常被忽略,什么也不做的catch块

3)移动的Server.Transfer到最后

Why am I getting the exception While executing the Server.Transfer()...

Server.Transfer(@"~/Student/StudentSendMail.aspx?username=" + username);

{Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}

解决方案

One cause of this strange error message is performing a Server.Transfer inside of a try-catch block. There are a couple of ways to handle that:

1) Add a second argument set to false like this:

Server.Transfer(@"~/Student/StudentSendMail.aspx?username=" + username, false);

2) Catch the Exception of type System.Threading.ThreadAbortException and do nothing in the catch block so the exception is ignored

3) Move the Server.Transfer to the Finally block

这篇关于asp.net的Server.Transfer()异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆