Cannot do response.redirect from page with Ajax controls

后端 未结 3 564
我在风中等你
我在风中等你 2021-01-16 17:07

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.

相关标签:
3条回答
  • 2021-01-16 18:00

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

    window.location = "[url to redirect]";
    
    0 讨论(0)
  • 2021-01-16 18:03

    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>
    
    0 讨论(0)
  • 2021-01-16 18:03

    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.

    0 讨论(0)
提交回复
热议问题