我在更新面板下的页面中编写了以下一段代码。在使用Response.Redirect时出现线程异常异常()
protected void myGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName =="EditNames")
{
long lSelectedName = Convert.ToInt64(e.CommandArgument);
Session["SelectedItem"] = lSelectedName;
Response.Redirect("EditItem.aspx");
}
else if (e.CommandName =="DeleteNames")
{
long lSelectedName = Convert.ToInt64(e.CommandArgument);
ValidName.DeleteItem(lSelectedName);
ScriptManager.RegisterStartupScript(this, GetType(), "Key", "alert('Name deleted sucessfully')", true);
}
}
catch (System.Threading.ThreadAbortException)
{
}
catch (Exception ex)
{
Error handling code...
}
在这里,我得到一个线程中止异常,而重定向。如何,我解决它通过使用错误处理程序System.threading.ThreadAbortException。
但是,我不确定为什么这个错误来了,而ridirecting。即便如此,我解决了这个问题,我想知道有没有在我编码或过程中的任何错误,有没有什么办法阻止错误在所有
烧给你的输入...
需要注意的是,该页面正在AJAX更新面板
可能重复的[为什么Response.Redirect导致System.Threading.ThreadAbortException?](http://stackoverflow.com/questions/2777105/why-response-redirect-causes-system-threading-threadabortexception) –