我收到错误“Thread is aborted”在我的以下代码上 [英] I am getting the error "Thread was being aborted" on my following code
本文介绍了我收到错误“Thread is aborted”在我的以下代码上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
User clsUser = null;
if (this.Userid.Text == "")
{
this.Userid.Focus();
throw new Exception("Please Enter User Name");
}
if (this.txtPssword.Text == "")
{
this.txtPssword.Focus();
throw new Exception("Please Enter Password");
}
clsUser = m_SecuritySys.checkUser(this.Userid.Text, m_SecuritySys.EncrypyPassword(this.txtPssword.Text));
if (clsUser != null)
{
if (clsUser.intStatus == 2 || clsUser.intStatus == 3)
{
}
else
{
Session["userid"] = clsUser.strUserId;
Session["username"] = clsUser.strUserName;
// Session["userstream"] = clsUser.userStream;
Response.Redirect("~/Default.aspx",true);
}
}
else
{
Userid.Focus();
throw new Exception("Invalid user entry, Please try again");
}
}
catch (System.Threading.ThreadAbortException ex)
{
DisplayCustomMessage(ex.Message);
}
finally
{
if (connection != null)
connection.Dispose();
}
推荐答案
当您在try catch中执行Response.Redirect时会发生这种情况。您可以放心地忽略此错误。
您可以在这里阅读更多内容, https:// support.microsoft.com/en-us/kb/312629 [ ^ ]
It happens when you do Response.Redirect in the try catch. You can safely ignore this error.
You can read more here, https://support.microsoft.com/en-us/kb/312629[^]
有一个奇怪的怪癖,如果你在try \catch中重定向,你会遇到这个问题。
http://blogs.msdn.com/b/tmarq/archive/2009/06/25/correct-use-of-system-web-httpresponse-redirect.aspx [ ^ ]
There is an odd quirk where if you redirect inside a try\catch you'll have this problem.
http://blogs.msdn.com/b/tmarq/archive/2009/06/25/correct-use-of-system-web-httpresponse-redirect.aspx[^]
已解决
我找到了错误解决方案,
<! [CDATA [<%@ Master Language =C# AutoEventWireup =true CodeBehind =Site.master.cs
Inherits =project。 SiteMaster%>
页面属性中的
就像这样AutoEventWireup =false
我将其更改为AutoEventWireup =true
问题已解决
Resolved
I found the error solution,
<![CDATA[<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs"
Inherits="project.SiteMaster" %>
in page attribute was like this AutoEventWireup="false"
and i changed this as AutoEventWireup="true"
problem resolved
这篇关于我收到错误“Thread is aborted”在我的以下代码上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文