【发布时间】:2014-01-17 10:29:27
【问题描述】:
我正在从 AJAX 调用一个函数
$.ajax({
type: "POST",
url: "GetOneApple",
data: {},
dataType: "json",
success: function (data) {}
});
家庭控制器:
[HttpPost]
public ActionResult GetOneApple()
{
try
{
..snip
}
catch (Exception e)
{
return RedirectToAction("ErrorPage", "Home");
}
}
在 catch 块中我也试过这个:
return new RedirectToRouteResult(new RouteValueDictionary {
{ "Controller", "Home" },
{ "Action", "ErrorPage" }
});
我有一个这样的 ErrorPage 控制器
public ActionResult ErrorPage()
{
return View();
}
正如我提到的,
如果 try 块中发生任何错误,它必须重定向到 ErrorPage
但是页面没有重定向,使用 firebug 我从控制器的 AjaxResponse 中获得了“ErrorPage”html,即使它没有重定向到“ErrorPage”view
我错过了什么?我对此有点陌生,所以希望有一个我无法找到的简单答案......
【问题讨论】:
标签: jquery asp.net-mvc asp.net-mvc-3 exception-handling handleerror