ELMAH忽略MVC 3网站异常

问题描述:

我不知道这是ELMAH或ASP.NET MVC3,或只是两者的结合问题:
我已经配置了我的MVC 3的网站使用ELMAH,但是当我使我的pretty错误页在web.config中,ELMAH停止记录异常。我曾经有过眼前这个在我的web.config,

I don’t know it this is an issue with ELMAH or ASP.NET MVC3, or just the combination of the two: I’ve configured my MVC 3 website to use ELMAH, but when I enable my "pretty" error page in web.config, ELMAH stops logging exceptions. I used to have just this in my web.config,

<customErrors mode="On" defaultRedirect="/Error.htm" redirectMode="ResponseRewrite"></customErrors>

不过,起初我并没有在我的共享文件夹中的Error.cshtml观点:ELMAH会记录异常失踪的错误观点,当一些其他异常被抛出。添加Error.cshtml视图之后,ELMAH不会记录任何异常了。

But at first I didn’t have an Error.cshtml view in my shared folder: ELMAH would log an exception for the missing Error view, when some other exception was thrown. After adding an Error.cshtml view, ELMAH doesn’t log any exceptions anymore.

我猜我需要配置MVC以不同的方式来处理异常,所以它们是由ELMAH回升,并最终ASP.NET踢,并显示错误.htm页。我怎么做?或者我使用MVC异常和/或ELMAH错了?

I’m guessing I need to configure MVC to handle exceptions in a different way, so they’re picked up by ELMAH, and the ASP.NET eventually kicks in and displays the error .htm page. How do I do that? Or am using MVC exceptions and/or ELMAH wrong?

看this直接从ELMAH笔者回答。也有在同一个线程另一个答案应该给你另一种方法

Look at this answer directly from the author of Elmah. There is also another answer in the same thread that should give you an alternative approach