Elmah 没有记录 HttpRequestValidationException
在我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这就是 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.