Elmah 没有记录 HttpRequestValidationException

发布于 2024-11-07 23:36:48 字数 1293 浏览 0 评论 0原文

在我的 ASP.NET MVC2 应用程序中,Elmah 无法记录任何 HttpRequestValidationException(除非您通过远程桌面登录到 Web 服务器并以 localhost 身份浏览该网站)

例如,如果我输入 &#当使用我得到的域名从我的电脑正常浏览时,将 39 输入到文本框中

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 

我知道为什么显示不同的错误消息,这是因为我没有 节点。但没关系,我不希望向全世界显示完整的错误消息。

但我真正想要的是 Elmah 在发生此错误时记录该错误。我需要做什么才能使其按预期工作?

In my ASP.NET MVC2 application Elmah fails to log any HttpRequestValidationException (except when you are logged into the webserver via remote desktop and browsing the site as localhost)

For example if I type ' into a textbox when browsing normally from my pc using the domain name I get

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".

And nothing shows in the Elmah log.

But if I log into the webserver via remote desktop and browse the site as localhost I can see the full error message:

Server Error in '/' Application.
A potentially dangerous Request.Form value was detected from the client 

I know why different error messages are shown, it is because I don't have a <customErrors mode="Off"/> node in my web.config. But that's ok, I do not want the full error message shown to the whole world.

But what I do want is for Elmah to log this error when it occurs. What do I need to do to get this to work as expected?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流殇 2024-11-14 23:36:48

我认为这就是 Elmah 缺陷 http://code.google.com/p/elmah/issues /detail?id=217 ,这是由 ASP.NET 4 中请求验证的重大更改引起的。该缺陷列出了两种可能的解决方法(通过在 Application_Error 处理程序中捕获该异常或关闭该异常,在 ELMAH 中手动记录该异常) Web.config 中的新验证行为)

请参阅此 博客帖子提供了解决方法。

I think this is this Elmah defect http://code.google.com/p/elmah/issues/detail?id=217 , which is caused by a breaking change in request validation in ASP.NET 4. The defect lists two possible workarounds (manually log the exception in ELMAH by catching it in the Application_Error handler or turning off the new validation behavior in the Web.config)

See this blog post providing a workaround.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文