Response.Redirect not ending execution Response.Redirect not ending execution asp.net asp.net

Response.Redirect not ending execution


The second parameter for Response.Redirect is endResponse, however the tooltip says 'Indicates whether execution of the current page should terminate'. This is misleading, because the execution of the page does not actually terminate when the variable is true. It will finish running any code. However what does happen differently, is the Render events are canceled, and the Response is immediately flushed with the object moved header.

You need to manually exit out of any methods, Response.Redirect / Response.End will not do that for you. Futhermore, if you need a conditional to see if the Page has been redirected, check out Response.IsRequestBeingRedirected.


are you exiting from the function that calls redirect, e.g.

...redirect(stopit,true);return;

?


Probably you are calling the Response.Redirect method inside a try{}catch{} block, try it by calling outside of this block and you'll see that it will not fail.More info:http://www.velocityreviews.com/forums/t72105-responseredirect-in-a-trycatch.htmlHope this helps.