Asp.net mvc HandleError属性不为';没有任何效果
在我的web.config中,我包括:Asp.net mvc HandleError属性不为';没有任何效果,asp.net-mvc,asp.net-mvc-3,handleerror,Asp.net Mvc,Asp.net Mvc 3,Handleerror,在我的web.config中,我包括: <customErrors mode="On" /> 但它没有任何效果,它与: public ActionResult About() { throw new Exception("Just an exception"); return View(); } 在这两种情况下,都会显示自定义错误页面。那么HandleError属性是什么呢?请参阅Scott Gu的以下文章。它包含有关HandleError属性的所有信息 如果MV
<customErrors mode="On" />
但它没有任何效果,它与:
public ActionResult About()
{
throw new Exception("Just an exception");
return View();
}
在这两种情况下,都会显示自定义错误页面。那么HandleError属性是什么呢?请参阅Scott Gu的以下文章。它包含有关HandleError属性的所有信息
如果MVC项目的App_Start文件夹下的FilterConfig.cs包含以下内容,则可能发生这种情况:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
由于HandleError筛选器是在应用程序启动时注册的,因此您不必使用此属性来修饰每个控制器操作。这是一个出色而简洁的解释,它也回答了以下问题:“RegisterGlobalFilters的用途是什么?”
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}