I had this error Thread was being aborted., this afternoon in my error log.
The code that caused this error is:
Response.Redirect("Login.aspx", true);
If I change the bool
value to false
, the error log becomes empty and this error stops coming again, but the program stops working.
If I keep it as such, I am getting this error like nuisance.
I want to know the alternative for using Response.Redirect
passing true
as the value for the endResponse
parameter.
As stated in
Response.Redirect(url)
ThreadAbortException Solution:Or simply move
Response.Redirect("~/Membership/UserRegistration.aspx");
out of the Try/Catch block.For all caught errors where you want to redirect, create a 'GoTo' destined out of the Try Catch as follows:
This neither causes thread abortion nor requires multiple catches.
I catch this exception and swallow it because ASP.NET is using exceptions for flow control rather than for an exceptional circumstance.
you can change like this Response.Redirect ("Login.aspx",false) then it wont abort.