当您返回 Json(...) 时,您明确告诉 MVC 不要使用 View ,并提供序列化的 JSON 数据。您的浏览器会打开一个下载对话框,因为它不知道如何处理这些数据。
我从下面的链接得到了以上信息
How to return Json object from MVC controller to view
当我在某些操作结果中给出下面的代码时
return Json(new { Url = "sep/employee"}
是否会重定向到指定的 Action ?它如何重定向到 URl ?
对于这种情况,为什么我不能使用 return RedirectToAction("sep/employee")。
返回 Json 代码如何重定向到 Url 中指定的操作。
例如:
public ActionResult Index()
{
................................
return Json(new { Url = "sep/employee"}
}
public ActionResult employee()
{
....................
}
b/s重定向和返回Json有什么区别
请您参考如下方法:
您将以下行返回给 ajax
success
调用
return Json(new { Url = "sep/employee"});
然后您需要指定重定向到新页面的位置
success: function(result) {
window.location.href=result.Url;
}