As per MSDN documentation, Redirect
method calls Response.End()
method which internally tries to raise ThreadAbortException
. If the attempt is successful the calling thread gets aborted which has adverse affect on your site performance.
It is advised and recommended to call the method as Response.Redirect(url, false)
. And then call CompleteRequest
method which causes ASP.NET by pass all its events in the HttpPipeline
directly jumping to EndRequest
method. See HttpPipeline
event model
Please note: CompleteRequest
allows your page life cycle event to execute. Consider following scenario.
Code Snippet
Line1: try {
Line2: Response.Redirect(url, true);
Line3: }
Line4: catch(ThreadAbortException ex) {
Line5:
Line6: }
In the above snippet if we pass true in Redirect
method, it will surely throw a ThreadAbortException
. So if we follow the Microsoft recommended solution, we don't need to add try..catch
block. Because CompleteRequest
method does not throws any exception neither interrupts the ASP.NET Page life cycle events, rather it jumps HttpPipeline
events (refer to this[^] link for Http Pipeline
event model).
Recommended: Code Snippet
Line1: Response.Redirect(url, false);
Line2: this.Context.ApplicationInstance.CompleteRequest();
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.