The second parameter overload of Response.Redirect is nice because it doesn’t call Response.End, which is responsible for throwing the ThreadAbortException. BUT…
The drawback to using this is that the page will continue to process on the server and be sent to the client. If you are doing a redirect in Page_Init (or like) and call Response.Redirect(url, false) the page will only redirect once the current page is done executing. This means that any server side processing you are performing on that page WILL get executed. In most cases, I will take the exception perf hit over the rendering perf hit, esp since the page won’t be rendered anyway and that page could potentially have a ton of data. Using Fiddler I was also able monitor my http traffic and see that when using this redirect method the page is actually being sent to the client as well.
I don’t usually do redirects in try/catch blocks, but if you do the ThreadAbortException will be handled by your catch and potentially cause a transaction Abort (depending on what you are doing of course). If you do put the redirect in the try block, then you’ll need to explicitly catch the ThreadAbortException or create a wrapper method that does that for you.
Something like this would work.
You can read more about Response.Redirect @ MSDN
Use of included code sample is subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
This posting is provided “AS IS” with no warranties, and confers no rights.