12
Say, I have a try/catch block that encapsulates a large block of code and then somewhere in it I need to call Response.Redirect as such:
protected void ButtonGo_Click(object sender, EventArgs e)
{
try
{
using(lockingMethod)
{
//Code...
//Somewhere nested in the logic
Response.Redirect(strMyNewURL);
//More code...
}
}
catch(Exception ex)
{
LogExceptionAsError(ex);
}
}
What happens in this case is that Response.Redirect throws an exception, something about terminating the thread, which I believe is a "normal flow of events" for that method, but it gets logged in my LogExceptionAsError as an error. So I was curious, is there any way to make Response.Redirect not throw exception?