Take for example the following code:
try
{
Response.Redirect(someurl);
}
finally
{
// Will this code run?
}
Try this:
try
{
Response.Redirect("http://www.google.com");
}
finally
{
// Will this code run?
// yes :)
Response.Redirect("http://stackoverflow.com/questions/3668422/will-code-in-finally-run-after-a-redirect");
}
The general rule is that the code in finally will be applied in all cases (try/catch)
Yes.
Try it and see!
It will run. Response.Redirect actually throws a ThreadAbortException, so that's why code after that will not run (except anything in a finally block of course).
Why do you not just try it?
finally
always runs, except in these extreme scenarios:
It will indeed. See this MSDN article: Finally always executes