在我的web.config中,我包括:
<customErrors mode="On" />
Run Code Online (Sandbox Code Playgroud)
现在黄色的死亡屏幕不再显示了.我以为我必须将HandleError属性包含在我的控制器方法或类本身中:
[HandleError]
public ActionResult About()
{
throw new Exception("Just an exception");
return View();
}
Run Code Online (Sandbox Code Playgroud)
但它没有任何影响,它是相同的:
public ActionResult About()
{
throw new Exception("Just an exception");
return View();
}
Run Code Online (Sandbox Code Playgroud)
在这两种情况下都会显示自定义错误页面.那么HandleError属性又是什么呢?