Click here to Skip to main content
15,921,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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]

C#
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);
        }
    }
}
Posted
v2

try this

Response.Redirect("ClientDetails.aspx", true);
 
Share this answer
 
try:
C#
Response.Redirect("ClientDetails.aspx", true);
 
Share this answer
 
v2
Refer - Response.Redirect causes System.Threading.ThreadAbortException[^].
Quote:

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:
C#
Response.Redirect(url, false);
Context.ApplicationInstance.CompleteRequest();

This blog[^] post from Thomas Marquardt provides additional details, including how to handle the special case of redirecting inside an Application_Error handler.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900