I have created a website using Asp.net and c#. I am handing exceptions and logging it into a log file(text file). In the catch statement, i decided to redirect the user to the login page whenever an exception is caught. But, in the log file, i am getting
as "Thread was being aborted" whenever an operation is performed. Why is this happening? Could anyone please help.
The link also says the same thing. But not the proper fix for the solution. Is it possible to use the Response.Redirect("loginpage.aspx,false) inside the catch block without getting the "Thread was being aborted" message
I don't think the line Response.Redirect("Loginpage.aspx",false); is the cause of the recorded exception, because it's not inside a try block, so its exception won't be catched and sequentially won't be recorded. BTW, Response.Redirect("Loginpage.aspx",false);
won't thow exception, this overriden method is different from the response.redirect("").
I think the cause may be in somewhere else, have you ever called response.redirect("") method inside a try block? change it to response.redirect("", false) may help.
venkatzeus
Participant
1633 Points
1022 Posts
Thread was being aborted
Dec 13, 2006 05:22 AM|LINK
Hi,,
I have created a website using Asp.net and c#. I am handing exceptions and logging it into a log file(text file). In the catch statement, i decided to redirect the user to the login page whenever an exception is caught. But, in the log file, i am getting as "Thread was being aborted" whenever an operation is performed. Why is this happening? Could anyone please help.
The catch code is as follows:
catch (Exception ex)
{
LogReport.ErrorReport(this.GetType().Name + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + ":" + ex.Message);
Response.Redirect("Loginpage.aspx",false);
}
LogReport is the class file where i have written the exception handling and ErrorReport is the method name.
raymond.wen
Participant
1237 Points
242 Posts
Re: Thread was being aborted
Dec 14, 2006 05:05 AM|LINK
http://support.microsoft.com/kb/312629/EN-US/
venkatzeus
Participant
1633 Points
1022 Posts
Re: Thread was being aborted
Dec 14, 2006 05:28 AM|LINK
raymond.wen
Participant
1237 Points
242 Posts
Re: Thread was being aborted
Dec 14, 2006 06:07 AM|LINK
I think the cause may be in somewhere else, have you ever called response.redirect("") method inside a try block? change it to response.redirect("", false) may help.
mattgroves
Member
30 Points
9 Posts
Re: Thread was being aborted
Jan 04, 2007 01:15 AM|LINK
Awesome Ramond, thankyou. That Microsoft support link resolved the problem.
Cheers,
Matt
Neilster
Member
2 Points
1 Post
Re: Thread was being aborted
May 25, 2010 10:54 AM|LINK
To fix, simply put the Response.Redirect in a finally statement, anywhere else in the try..catch witll result in a ThreadAborted exception
AhsanRazaUK
Member
2 Points
1 Post
Re: Thread was being aborted
Oct 31, 2012 11:13 AM|LINK
Had same problem.. Response.Redirect(""); in try{} block logs same error. Response.Redirect("", false); worked for me.