在与 RegisterGlobalFilters 和 HandleErrorAttribute 一直苦苦挣扎之后,我决定回到最基本的框架。我使用模板在 VS10 中创建了一个新的 MVC 3 项目。在 About-action 中添加 throw DivideByZeroException 并启动开发服务器。预计不会看到黄屏。
但我做到了。
为什么这对我不起作用?
更新
archil 和 Adam Tuliper 的建议有点奏效。错误视图被调用。
然后我继续在 RegisterGlobalFilters 中添加它。
filters.Add(new HandleErrorAttribute { ExceptionType = typeof(DivideByZeroException), View = "DivideByZeroException", Order = 1 });
filters.Add(new HandleErrorAttribute { View = "AllOtherExceptions", Order = 2 });
调用了 AllOtherExceptions 视图。为什么不使用 DivideByZeroException 视图?
后续问题已在此处发布。