我在使用和不使用'ExceptionType‘参数时都尝试过。我在Views/Shared文件夹和Views/thisController文件夹中都有一个Error.aspx页面。但每次我运行它时,我都会得到一个“'/‘应用程序中的服务器错误”。错误页面,而不是视图/共享中的漂亮页面。
你知道这里会出什么问题吗?
[HandleError(View="Error",ExceptionType=typeof(FormatException))]
public ActionResult Create()
{
throw new Exception();
//int breakMe = int.Parse("not a number");
return View();
}发布于 2008-12-03 01:32:51
我的web.config里确实有这个
<customErrors mode="On"></customErrors>一定有别的原因在起作用。
发布于 2008-12-03 01:21:42
它对我当前的项目或新的项目都不起作用。这可能是一个“特性”。
EDIT:看起来你已经启用了customErrors (mode="On"),它可以根据HandleErrorAttribute.cs中的这段代码来工作:
// If custom errors are disabled, we need to let the normal ASP.NET exception handler
// execute so that the user can see useful debugging information.
if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled) {
return;
}https://stackoverflow.com/questions/335841
复制相似问题