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.
I catch this exception and swallow it because ASP.NET is using exceptions for flow control rather than for an exceptional circumstance.
try
{
// Do stuff.
}
catch(ThreadAbortException)
{
// Do nothing. ASP.NET is redirecting.
// Always comment this so other developers know why the exception
// is being swallowed.
}
catch(OtherExceptionTypes ex)
{
// Log other types of exception.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With