I have a page with several user controls that use Ajax. When I try to do a response.redirect from this page, Ajax traps the call and does not allow the redirect.
How can I do a response.redirect from an Ajax page?
Thanks...
I have a page with several user controls that use Ajax. When I try to do a response.redirect from this page, Ajax traps the call and does not allow the redirect.
How can I do a response.redirect from an Ajax page?
Thanks...
How much control over the AJAX actions do you have in the user controls? If you can modify the client side, the easiest thing to do is to return a JSON object that you can parse and send the URL that you want to redirect to as data. Once you get the data on the client, simply set window.location.href to the url.
With jQuery it would look something like:
$.ajax({
url: '/some/url',
dataType: 'json',
type: 'post',
data: $('form').serialize(),
success: function(data) {
if (data.Redirect) {
window.location.href = data.Redirect;
}
else {
...handle other responses...
}
}
... more options...
});
as I stated in the other question:
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>
Here is blog post that will help you to resolve the issue.
http://patelshailesh.com/index.php/response-redirect-throws-an-error-when-called-inside-update-panel