重定向不起作用并返回错误0

时间:2014-01-29 16:19:42

标签: jquery asp.net asp.net-mvc asp.net-mvc-4

我在redirection中制作controller

return Redirect("http://another.domainThanTheCurrentApllication.com/sso?token=token==");

此控制器由

调用
$(document).on("click", ".rounded-button > a", function () {
            hideContent();
            $('#Content').load(this.href, function (response, status, xhr) {
                showContent();
                if (status == "error") {
                    var msg = "Sorry but there was an error: ";
                    $("#cloudContent").html(msg + xhr.status + " " + xhr.statusText);
                }
                cufonStyle();
            });
            return false;
        });

partialView正常,状态为" error"。在部分占位符中输出的消息是" Sorry but there was an error: 0",并且没有重定向。 重定向中没有例外。

我测试了重定向的网址,它在我的浏览器中运行良好。

感谢帮助我,

1 个答案:

答案 0 :(得分:0)

.load()方法用于从服务器获取数据并放入匹配的元素中。在这里,你完全违背了ajax和load()功能的目标。

在点击功能中,您可以像这样重定向

 window.location.href = "http://another.domainThanTheCurrentApllication.com/sso?token=token=="

或者如果你想从服务器获取重定向网址

$.ajax({
type: "GET",
    url:this.href,
    success: function(data, textStatus, xhr) {
       window.location.href = data.url;
    }

并在控制器中

    return Json(new { url = "http://another.domainThanTheCurrentApllication.com/sso?token=token==" });
相关问题