Response.Redirect in ASP.NET AJAX calls

余生颓废 提交于 2019-12-01 12:39:39

Did you give a try for redirecting to a relative path? Something like below?

Response.Redirect("~/Test.aspx") 

Please give the correct relative path where the Test.aspx resides. Hope this helps.

You can't redirect in an async postback. Add the button as a PostBackTrigger:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
        <asp:PostBackTrigger ControlID="Button1" />
    </Triggers>
    <ContentTemplate>

    </ContentTemplate>
</asp:UpdatePanel>   

The other solution is to add the following script module 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>

in your ajax callback handler you should check 301 status code and redirect like below

response = ajaxContext.get_response();
if (response.get_statusCode() == 301)
  window.location = response.getResponseHeader('Location');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!