Reputation: 475
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....
Upvotes: 1
Views: 3700
Reputation: 10865
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>
Upvotes: 1
Reputation: 4595
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.
Upvotes: 0
Reputation: 8921
Instead of using Response.Redirect, you can use Javascript to redirect.
window.location = "[url to redirect]";
Upvotes: 2