Problem in Response.redirect method

Posted by Prabu_Spark under ASP.NET on 6/20/2013 | Points: 10 | Views : 835 | Status : [Member] | Replies : 3
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);
}
}
}

With regards,
J.Prabu.
[Email:prbspark@gmail.com]



Responses

Posted by: Jitendrasoft09 on: 6/20/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi,

If Exception occurs you will not show another page, let to display error message, you need to add below code as mentioned in link that would be helpful for you and you need to check how much time to take execute the stored procedure.

db.ApplicationInstance.CompleteRequest();


http://stackoverflow.com/questions/2777105/response-redirect-causes-system-threading-threadabortexception

Jitendra Kumar
If my post helps you, plz mark as an answer.

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 6/20/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Use the below code:-

if (Convert.ToString(ex1.Message) == "Thead was being aborted.")
{
//Your code.
}

Hope this will help you.

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: lakhansin-22735 on: 7/14/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

If above code working fine then you have to navigate using below syntax
Here, I have replace 'false' by 'true' just try it.
Response.Redirect("ClientDetails.aspx",true); 


Thanks

Lakhan Singh
Tech Lead
BeyondKey System Pvt. Ltd.
Indore, M.P.
India

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response