Tuesday, February 20, 2007

Handling "Thread was being aborted" error in ASP.NET

Handling "Thread was being aborted" error in ASP.NET

This error occurs when you have used the following statements in code behind
due to the execution of Response.End() method.

1) Response.Redirect()
2) Server.Transfer()
3) Response.End()

Because the (1) & (2) statements internally executes Response.End().

To overcome this error

1) Response.Redirect(URL,false);
2) Give this statements within
try { }
catch { }
3) Use HttpContext.Current.ApplicationInstance.CompleteRequest() method
Instead of Response.End()

No comments: