If you are monitoring errors of your application you might have noticed that in your error log file lots of 'Thread was being aborted' exception logged.
This Exception occurs when you use Response.Redirect inside of a Try / Catch block. Your code will work and the browser will be redirected but that is reason of getting lots of alerts.
If you are passing QueryString then your application may not work properly because of this issue, so it is important to handle or avoid this kind of exceptions.
There are different ways to resolve this issue,
Hope this helps you someway. Thank you!!!
This Exception occurs when you use Response.Redirect inside of a Try / Catch block. Your code will work and the browser will be redirected but that is reason of getting lots of alerts.
If you are passing QueryString then your application may not work properly because of this issue, so it is important to handle or avoid this kind of exceptions.
There are different ways to resolve this issue,
- Simplest way to move the Response.Redirect outside the Try/Catch block.
- Catch Exception and do nothing,
try
{
if (Condition)
Response.Redirect("newpage.aspx”);
}
catch (ThreadAbortException ex)
{
// do nothing
}
catch (Exception e)
{
//Write your Error log logic
}
- Use overload of Redirect method like, Pass false as second parameter to this overload. Response.Redirect("newpage.aspx”,false);
Hope this helps you someway. Thank you!!!
B.Sagar