I'd recommend against using 'catch-all' blocks unless absolutely necessary.
Response.Redirect
always throws a ThreadAbortedException
by design (like it or not), unless you pass in the false
for the second parameter.
If you specify true for the endResponse
parameter, this method calls the End
method for the original request, which throws a ThreadAbortException
exception when it completes. This exception has a detrimental effect on Web application performance, which is why passing false for the endResponse
parameter is recommended.
Any other exceptions it throws indicate a invalid parameter or bad program state. You probably don't want to just ignore these errors and move on as though nothing has happened. I recommend you just do this:
public static void ReferToPage(string strPageName)
{
HttpContext.Current.Response.Redirect(strPageName, false);
}
false
as the second parameter keeps theRedirect
method from throwing an exception. There will never be any exception to catch (unless you call it too late so that the redirection is not possible any more). – Guffa Jun 7 '13 at 16:03