I have Default.aspx page, which inherits from BasePage.cs, which inherits from System.Web.UI.Page. BasePage is where I do some common things every page must do upon loading
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.html Hope this helps.
I'm going to get down voted for this! Curse my ignorance...
Obviously you could try adding the following line after the redirect (as pointed out by recursive),
response.end()
But maybe the reason the response.redirect is not immediately causing redirection is that you have response buffering on (the default) and the page processing is not ended until after the buffer is flushed. If this were true (and admittedly I'm to lazy too try) then adding the following line would also solve you problem.
response.flush()
You can throw an exception, that will exit code execution, but still redirect:
HttpContext.Current.Response.Redirect("/login", true);
throw new Exception("Unauthorized Access");
For an unconditional termination, you could try a
Response.End()
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;
?