【发布时间】:2011-06-11 19:36:02
【问题描述】:
我想处理应用程序范围的错误并在 asp.net mvc 中显示 ErrorView 页面。 有 3 种方法可以做到(或者我知道)。
1) ErrorAttribute in BaseController:Controller class.
Can be used on individual Action/Controller/BaseController.
2) Override OnException() in the BaseController:Controller class.
Will work on Controllers derived from BaseController
3) Application_Error in Global_aspx.
最佳做法是什么。 这些方法中的哪一种应该用于应用程序范围的错误处理,或者我们应该使用多种还是只使用一种。
如果我们在 BaseController 上的 ErrorAttribute 或/和 OnException() 上处理错误,我们是否仍应在 Application_Error() 中处理它。
我们什么时候应该使用 Application_Error()?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-2 application-error onexception