gpt4 book ai didi

asp.net-mvc-2 - 无法在 ELMAH 中记录代码 500 错误

转载 作者:行者123 更新时间:2023-12-03 21:27:26 24 4
gpt4 key购买 nike

在 IIS 7 中运行的 ASP.NET 4.0 MVC 项目中,我设置并配置了 ELMAH 以在我的站点上记录错误。但是,我无法获得任何关于代码 500 错误的报告。

我设置了一个简单的 Controller ,它创建了一个被零除的异常,但 ELMAH 没有记录它。我可以让 ELMAH 很好地记录其他消息,而且我没有过滤掉 ErrorLog_Filtering 中的任何异常。

此外,为了显示自定义页面,我更新了 web.config 的 httpErrors 部分,如下所示:

<customErrors mode="RemoteOnly" defaultRedirect="~/error/GenericError">
<error statusCode="403" redirect="~/error/AccessDenied" />
<error statusCode="404" redirect="~/error/NotFound" />
<error statusCode="500" redirect="~/error/Offline" />
<error statusCode="501" redirect="~/error/Offline" />
<error statusCode="503" redirect="~/error/Offline" />
</customErrors>


<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" >
<error statusCode="403" prefixLanguageFilePath="" path="/error/AccessDenied" responseMode="ExecuteURL" />
<error statusCode="404" prefixLanguageFilePath="" path="/error/NotFound" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/error/GenericError" responseMode="ExecuteURL" />
<error statusCode="501" prefixLanguageFilePath="" path="/error/GenericError" responseMode="ExecuteURL" />
<error statusCode="503" prefixLanguageFilePath="" path="/error/Offline" responseMode="ExecuteURL" />

最后,在查看应用程序日志文件时,代码 500 错误消息不会显示在那里。

是否有我遗漏的配置,或者我以某种方式不小心自己捕获了错误而不让它传播?

最佳答案

您需要删除添加过滤器的行 HandleErrorAttributeRegisterGlobalFilters()在 FilterConfig.cs 中。更多详情请见 this question .

关于asp.net-mvc-2 - 无法在 ELMAH 中记录代码 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3540163/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com