Calling Response.RedirectLocation from within ICallbackEventHandler.RaiseCallbackEvent does nothing

3.9k Views Asked by At

We're attempting to make a redirect during a page callback. We have an aspx page that is implementing ICallbackEventHandler. Inside of the ICallbackEventHandler.RaiseCallbackEvent() event handler in the code-behind we're attempting to use the Response.RedirectLocation to move the user on to another aspx page. Our code is below.

void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
    HttpContext.Current.Response.RedirectLocation = "http://www.google.com";
    HttpContext.Current.Response.End();
}

After raising the event client-side and setting breakpoints in the event handler we are sure that the code is being called but the page doesn't actually redirect. Are we missing something important here? We've tried several other ways including setting the Response.StatusCode and using Flush() instead of End(). Let me know if you need any additional information about what we're trying to do.

Any ideas would be greatly appreciated!

Thanks, Daniel

2

There are 2 best solutions below

0
On BEST ANSWER

The old fashioned way was Response.Redirect(url). Does that fix it?

0
On

I did it without the last line and it works.

HttpContext.Current.Response.RedirectLocation = "http://www.google.com";