user3529113
user3529113

Reputation: 1

Thread was being aborted exception in ASP.NET

Code is :

Response.Redirect("~/Admin/uploadMaterials.aspx",false);

After this redirect line is executing page is loading, not redirecting to uploadMaterials.aspx

Upvotes: 0

Views: 971

Answers (2)

JLRishe
JLRishe

Reputation: 101652

From the MSDN documentation:

Redirect calls End which raises a ThreadAbortException exception upon completion.

You should catch and ignore the ThreadAbortException, and then your redirect should work:

try
{
    // Code that calls Response.Redirect
}
catch (ThreadAbortException)
{
    // Do nothing
}
catch (Exception e)
{
    // Handle other exceptions
}

Upvotes: 1

Anthony Horne
Anthony Horne

Reputation: 2522

You can use server.transfer instead (or use the Response.redirect(....,true) to quit running the current page code and go to the next - but I have had a few GPF as a result.

Upvotes: 0

Related Questions