我已尝试过其他帖子here中列出的步骤
和here它只是不起作用。我最终被重定向到一个只是说...... {"redirectTo":"/Administrator/Home"}
#
[HttpPost]
public JsonResult ControllerMethodHere(ViewModel model) {
// my controller code goes here.
return Json(new {
redirectTo = Url.Action("Index", "Home"),
}, JsonRequestBehavior.AllowGet);
}
this.save = function () {
$.ajax({
url: $('form').attr('action'),
type: "POST",
data: ko.toJSON(this),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
window.location.href = data.redirectTo;
}
});
};
答案 0 :(得分:6)
尝试使用:
window.location = data.redirectTo;