【发布时间】:2012-02-17 13:11:22
【问题描述】:
我已经在 VS10 中启动了一个 MVC 3 模板项目并修改了 global.asax.cs:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute { ExceptionType = typeof(DivideByZeroException), View = "DivideByZeroException", Order = 1 });
filters.Add(new HandleErrorAttribute { View = "AllOtherExceptions", Order = 2 });
}
我在 web.config 中添加了:
<customErrors mode="On">
然后创建了相应的视图,最后在其中一个动作中添加了 DivideByZero-throw。
结果:视图 AllOtherExceptions 被渲染。
【问题讨论】: