在response.redirect("Default.aspx")之后线程被中止. [英] Thread was being aborted after response.redirect("Default.aspx")

查看:53
本文介绍了在response.redirect("Default.aspx")之后线程被中止.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误消息:

_message = "Thread was being aborted."

当我这样做

Response.Redirect("Default.aspx")

有人可以帮助我吗?

推荐答案

您可以执行以下操作:

Response.Redirect("Default.aspx", false);
return;

这不会结束响应,因此不会引发ThreadAbortException.调用return可以确保不会不必要地执行以下逻辑.

This doesn't end the response, so no ThreadAbortException is thrown. Calling return makes sure no following logic is executed unnecessarily.

msdn链接 https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx 表示以下内容:

The msdn link https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx says the following:

将endResponse设置为false,然后调用CompleteRequest方法.如果为endResponse参数指定true,则此方法将为原始请求调用End方法,该方法在完成时将引发ThreadAbortException异常.此异常对Web应用程序性能有不利影响,这就是为什么建议为endResponse参数传递false的原因.

set endResponse to false and then call the CompleteRequest method. If you specify true for the endResponse parameter, this method calls the End method for the original request, which throws a ThreadAbortException exception when it completes. This exception has a detrimental effect on Web application performance, which is why passing false for the endResponse parameter is recommended.

这篇关于在response.redirect("Default.aspx")之后线程被中止.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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