Click here to Skip to main content
15,887,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have gridview as follows


Code Name Season Village Govcode DOB Actions
1 Ram 2012 ALKO 789 12.10.86 Edit Delete
2 Sam 2013 Vino 545 12.5.87 Edit Delete

When i click the Edit in the gridview it will redirect to farmerpage.
But error shows the thread was being aborted

My edit code as follows

protected void onCommand(object sender, CommandEventArgs e)
{
try
{
if (e.CommandName == "Edit")
{
Response.Redirect("~/ivorycoast/farmerpage.aspx?action=edit&farmercode=" + e.CommandArgument.ToString());
}
}
catch (Exception ex)
{

}

But when i run the above code it shows error as follows

The Thread was being aborted.

what is the mistake in my above code.

What I have tried:

i have gridview as follows


Code Name Season Village Govcode DOB Actions
1 Ram 2012 ALKO 789 12.10.86 Edit Delete
2 Sam 2013 Vino 545 12.5.87 Edit Delete

When i click the Edit in the gridview it will redirect to farmerpage.
But error shows as the thread was being aborted

My edit code as follows

protected void onCommand(object sender, CommandEventArgs e)
{
try
{
if (e.CommandName == "Edit")
{
Response.Redirect("~/ivorycoast/farmerpage.aspx?action=edit&farmercode=" + e.CommandArgument.ToString());
}
}
catch (Exception ex)
{

}

But when i run the above code it shows error as follows

The Thread was being aborted.

what is the mistake in my above code.
Posted
Updated 27-Jun-18 5:32am

Quote:
what is the mistake in my above code.
Start by writing out 100 times: "I must not swallow exceptions".

Empty catch blocks don't fix problems - they hide them for later, and discard the very information you need to fix them. LOg the error, the error message, any inner exception, the whole nine yards. Then after the problem occurs you can look at the log and get some idea of why it happened.

But swallowing the exception means you don't get that, and have no idea what actually caused the problem ... and neither do we.
 
Share this answer
 
C#
Response.Redirect("~/ivorycoast/farmerpage.aspx?action=edit&farmercode=" + e.CommandArgument.ToString(), false);
Application.CompleteRequest();

ASP.NET Response.Redirect without ThreadAbortException[^]
 
Share this answer
 
Comments
nar86 29-Jun-18 1:41am    
i also tired the below two code both are not working and it is not redirect to farmerpage

Response.Redirect("~/ivorycoast/farmerpage.aspx?action=edit&farmercode=" + e.CommandArgument.ToString(), false);
Application.CompleteRequest();


Response.Redirect("~/ivorycoast/farmerpage.aspx?action=edit&farmercode=" + e.CommandArgument.ToString(), false);
HttpContext.Current.ApplicationInstance.CompleteRequest();

can any one please me. i am facing this issue for long time.

do you need any information other than this. please let me know.

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