更新时间:2023-11-21 11:00:16
当你请求AJAX调用,你应该使用重定向其响应
As you requesting AJAX call, you should redirect using its response
修改您的控制器与登陆网址返回JSONResult:
Modify your controller to return JSONResult with landing url:
public ActionResult SetEnddateRemarkToYesterday(int remarkID) {
//Some logic to persist the change to DB.
var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Controller");
return Json(new { Url = redirectUrl });
}
JS调用:
$.post("Home/SetEnddateRemarkToYesterday", { remarkID: remarkID }, function (result) {
window.location.href = result.Url
});