我看过在ASP.NET MVC 3应用程序中实现全局错误处理的两种方法。其中一种方法是通过Global.asax.cs
中的Application_Error
方法。
例如(Error Handling in global.asax):
public class SomeWebApplication : System.Web.HttpApplication {
// ... other methods ...
protected void Application_Error() {
// ... application error handling code ...
}
}
另一种方法是通过在
Global.asax.cs
中的RegisterGlobalFilters
方法中注册的[HandleError]
操作过滤器属性来实现。哪种方法更好?这两种方法是否存在任何重大缺点?
<customErrors>
部分。 - jgauffincustomErrors
和错误控制器。 - jgauffin