开发者

Error logging in ASP.NET MVC 3

开发者 https://www.devze.com 2023-02-18 05:21 出处:网络
I am logging errors in my ASP.NET MVC 3\'s Application_Error method in the Global.asax file. My problem is that if customErrors in Web.config is set to true no logging happens. It does happen if it is

I am logging errors in my ASP.NET MVC 3's Application_Error method in the Global.asax file. My problem is that if customErrors in Web.config is set to true no logging happens. It does happen if it is set to Off. If an exception is thrown, Application_Error开发者_运维问答 will always be called no matter the customError settings - or so I thought? What is up?


The possible values of the mode attribute are On, Off and RemoteOnly so I suspect that if you set it to true your application wouldn't even load.

On the other hand if you set mode="On" in case of an exception there is a global error filter in ASP.NET MVC 3 (see the RegisterGlobalFilters method in your Global.asax) which kicks in and automatically renders the ~/Views/Shared/Error.cshtml view => in this case the Application_Error method won't be called because the exception is handled.

0

精彩评论

暂无评论...
验证码 换一张
取 消