重定向 Jquery Ajax 成功无效

redirect on Jquery Ajax success not working

Jquery代码:

$.ajax({
                    type: "POST",
                    async: false,
                    cache: false,
                    url: "ManageUsers/ValidateReportUsers.aspx/allocateSessionRedirect",
                    data: '{id:"'+flag+'"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        if (response.d == true) {
                            alert("You will now be redirected.");

                            window.location.href = "/DownloadReport.aspx";

                        }
                    }

                });

Web Method code :

 public static bool allocateSessionRedirect (int id)
         {
             // set of codes here
               return true;

         }

浏览器显示警告消息"You will now be redirected."但不执行window.location.href = "/DownloadReport.aspx"; 我试过 window.location="/DownloadReport.aspx"; 以及 window.location.assign("/DownloadReport.aspx");

但没有用。请指教

改用location.assign("URL");。应该可以。

希望对您有所帮助。

设置按钮属性如下:-

OnClientClick="return false"

按钮正在回发。因此,重定向不起作用。