views:

946

answers:

3

I have a page that contains many user controls, each of which uses Ajax. When I load this page, under certain conditions, I want to do a response.redirect; however response.redirect statement is being trapped by Ajax code and never happens.

How do I do a response.redirect from a page that contains Ajax controls?

Thanks....

A: 

Instead of using Response.Redirect, you can use Javascript to redirect.

window.location = "[url to redirect]";
Adrian Godong
A: 

The redirect won't redirect the user but instead it will redirect the XmlHttpRequest instead of the request the user made to get to the page. You can set the location.href in your javascript based on the value returned from the ajax call.

olle
A: 

add this to your web.config:

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
Russ Bradberry