在我的 ASP.NET MVC2 应用程序中,Elmah 无法记录任何HttpRequestValidationException
(除非您通过远程桌面登录网络服务器并以本地主机身份浏览该网站)
例如,如果我输入'
使用我获得的域名从我的电脑正常浏览时进入文本框
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom
error settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could, however,
be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on
remote machines, please create a <customErrors> tag within a "web.config"
configuration file located in the root directory of the current web application.
This <customErrors> tag should then have its "mode" attribute set to "Off".
Elmah 日志中没有显示任何内容。
但是,如果我通过远程桌面登录网络服务器并以本地主机身份浏览该网站,我可以看到完整的错误消息:
Server Error in '/' Application.
A potentially dangerous Request.Form value was detected from the client
我知道为什么会显示不同的错误消息,那是因为我没有<customErrors mode="Off"/>
我的 web.config 中的节点。但没关系,我不希望向全世界显示完整的错误消息。
但我真正想要的是 Elmah 在发生此错误时记录该错误。我需要做什么才能使其按预期工作?
我想这就是Elmah的缺陷http://code.google.com/p/elmah/issues/detail?id=217 http://code.google.com/p/elmah/issues/detail?id=217,这是由 ASP.NET 4 中请求验证的重大更改引起的。该缺陷列出了两种可能的解决方法(通过在 Application_Error 处理程序中捕获异常或关闭 Web.config 中的新验证行为来手动记录 ELMAH 中的异常)
看到这个博客文章 http://ivanz.com/2011/05/08/asp-net-mvc-magical-error-logging-with-elmah/提供解决方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)