MVC 4 - 如何关闭默认Error.vbhtml页面? [英] MVC 4 - How do I turn off the default Error.vbhtml page?

查看:145
本文介绍了MVC 4 - 如何关闭默认Error.vbhtml页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何关闭默认的错误页面或者它引用??

Anyone know how to turn off the default error page or where it's referenced??

推荐答案

好吧,我想它了。

原来,在我的自定义ElmahHandleErrorAttribute类中,onException的()方法确实超过缠身(因为它应该是)。但是,code的第一行是MyBase.OnException(上下文),这将断火什么的HandleError属性也执行。

Turns out that in my custom ElmahHandleErrorAttribute class, the OnException() method is indeed over ridden (as it should be). But the 1st line of code is "MyBase.OnException(context)", which will fire off what the HandleError attribute also performs.

在我注释掉了一条线,我的问题就走开了。

Once I commented out that one line, my issue went away.

什么是问题?

我已经Elmah.Mvc这个Mvc4项目实施,它的工作精美。我也有在Web.config自定义错误部分如下:

I have Elmah.Mvc implemented in this Mvc4 project, it's working beautifully. I also have a custom errors section in the Web.config as follows:

<customErrors mode="On" defaultRedirect="~/Error/General">
  <error statusCode="404" redirect="~/Error/Http404" />
</customErrors>

我有两个动作方法,一个是一般,另一个为ErrorControllerHTTP404。

I have an ErrorController with two action methods, one for "General" and the other for "Http404".

发生了什么事是,如果我引发未处理的错误,我的确会得到ELMAH登录我提出的例外,例外交付的邮件,然后自定义常规视图中显示(HTTP404页面,如果它是一个404错误)。

What was happening was if I raised an unhandled error, I would indeed get my raised exception logged in Elmah, an email delivered with the exception, and then the custom "General" view displayed (Http404 page if it was a 404 error).

但是,什么我也得到了一个额外的记录的异常,电子邮件,因为默认的Error.vbhtml文件未找到(我删除这一观点)。

BUT, what I was also getting was an additional logged exception AND email because the default "Error.vbhtml" file was not found (I removed that view).

诚实的错误...希望这有助于有人出来走动了。 :)

Honest mistake...hope this helps someone out moving along. :)

这篇关于MVC 4 - 如何关闭默认Error.vbhtml页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆