Response.redirect方法中的问题 [英] Problem in Response.redirect method
问题描述
先生,
我无法重定向到另一个页面,我得到了异常,因为线程正在中止。我使用ThreadAbortException处理
异常,但仍无法解决此问题。请给我这个问题的解决方案
。
[注意:我使用存储过程sp_replace_det_alpha来更新12000条记录]
Hi sir,
I cant able to redirect to another page, i got the exception as "Thread was being aborted". I handle that
exception using ThreadAbortException , still i cant able to solve this problem. Kindly give me the solution for
this problem.
[Note: I am using stored procedure sp_replace_det_alpha to update 12000 records]
protected void Button1_Click(object sender, EventArgs e)
{
try
{
DataSet ds1 = new DataSet();
db.executenonproce_withoutparams("sp_replace_det_alpha", out ds1);
Response.Redirect("ClientDetails.aspx",false);
}
catch (ThreadAbortException ex1)
{
if (ex1.Message == "Thead was being aborted.")
{
Response.Redirect("ClientDetails.aspx", false);
}
}
}
推荐答案
试试这个
Response.Redirect(ClientDetails.aspx,true);
try this
Response.Redirect("ClientDetails.aspx", true);
尝试:
try:
Response.Redirect("ClientDetails.aspx", true);
请参阅 - Response.Redirect导致System.Threading。 ThreadAbortException [ ^ ]。
Refer - Response.Redirect causes System.Threading.ThreadAbortException[^].
正确的模式是调用重定向
重载 endResponse = false
并打电话告诉IIS管道它应该直接前进到 EndRequest
阶段一旦你回归控制:
The correct pattern is to call the Redirect
overload with endResponse=false
and make a call to tell the IIS pipeline that it should advance directly to the EndRequest
stage once you return control:
Response.Redirect(url, false);
Context.ApplicationInstance.CompleteRequest();
这blog [ ^ ]来自Thomas Marquardt的帖子提供了更多详细信息,包括如何处理在 Application_Error
处理程序内重定向的特殊情况。
This blog[^] post from Thomas Marquardt provides additional details, including how to handle the special case of redirecting inside an Application_Error
handler.
这篇关于Response.redirect方法中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!