Exception on Response.Redirect
-
Hi, Doing Repsonse.redirect causes an Exception with following message "Thread was being aborted". Do some one has any explanation for this ?? I need to catch any runtime error that occured and then redirect to a generic error page and in case of no error redirect user to another page. Now every time i do Response.Redirect, even on clean(no errors) execution, i got this exception. How to avoid this ?? Thanks in Advance, Regards.
-
Hi, Doing Repsonse.redirect causes an Exception with following message "Thread was being aborted". Do some one has any explanation for this ?? I need to catch any runtime error that occured and then redirect to a generic error page and in case of no error redirect user to another page. Now every time i do Response.Redirect, even on clean(no errors) execution, i got this exception. How to avoid this ?? Thanks in Advance, Regards.
Hi, this is not error, because if you call Response.Redirect with second parameter (end response immediately) set to true it will call Response.End() and there is no other way for Asp.Net to end response withou executing the rest of code than throwing exception. You can avoid this by calling redirect like this (but i think, that it is better to ignore this exception, than trying to avoid it):
Response.Redirect("redirecturl.aspx",false);
return;Tomáš Petříček (Microsoft C# MVP)
www.eeeksoft.net | Photos | Fractal Snow