Home » ASP.Net, Tech Corner

‘Thread was being aborted’on using Response.Redirect,Response.End

21 October 2009 No Comments Posted By:Vivek

This is a very common error that is encountered.This is because Response.End ends the Page Execution and transfers the execution to Application_EndRequest event and the line following the Response.End is not executed.
This problem occurs for the Response.Redirect method also as when this method is used, an internal call to Response.End is made.


How to resolve it?
Instead of Response.End,use HttpContext.Current.ApplicationInstance.CompleteRequest method.
For Response.Redirect,set the endResponse parameter in the method to false.It indicates that the execution of the current page should not terminate.
Eg:

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

This error also happens when Server.Transfer method is called.Just use Server.Execute method instead.

Related posts:

  1. FileUpload Control
  2. How to Bind Images from Database in a GridView
  3. Dropdownlist inside a Gridview
  4. .NET Interview Questions & Answers
  5. Multiview and View controls in ASP.NET(3.5)

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>