简体   繁体   English

关闭HttpRequestValidationException日志记录?

[英]Turn off HttpRequestValidationException logging?

We have an exception that keeps cropping up in our Event Viewer logs for our server, caused by explicit attempts to hack our site by our PCI security company. 我们有一个例外情况,在我们的服务器的事件查看器日志中不断出现,这是由我们的PCI安全公司明确企图破解我们的网站造成的。 It gets annoying as it crops up all the time, and initially it was generating the 'yellow screen of death' and logging in the event viewer as an unhandled exception. 随着它一直在崛起,它变得很烦人,最初它产生了“黄色死亡屏幕”,并在事件查看器中记录为未处理的异常。 We put an exception handler around the code where he exception was coming from (inside Phalanger if you are interested), so it now longer crashes and causes the yellow screen of death, but it STILL ends up in the event viewer logs as a warning! 我们在异常来自的代码周围放置了一个异常处理程序(如果你感兴趣的话,在Phalanger里面),所以它现在更长时间崩溃并导致死亡的黄色屏幕,但它仍然在事件查看器日志中作为警告结束!

Any idea how to turn it off in the event viewer short of turning off request validation completely, which I was trying to avoid? 任何想法如何在事件查看器中关闭它完全关闭请求验证,我试图避免?

We are using ASP.NET MVC 3 so I know I can use the new ValidateInput attribute to do this, but I would rather leave it turned on but be able to handle the exceptions ourselves and not have them get logged to the event viewer even though I catch it and handle it? 我们正在使用ASP.NET MVC 3所以我知道我可以使用新的ValidateInput属性来执行此操作,但我宁愿让它保持打开但能够自己处理异常而不是让它们记录到事件查看器中,即使我抓住它并处理它?

Add following code to Global.asax.cs 将以下代码添加到Global.asax.cs

    void Application_Error(object sender, EventArgs e)
    {
        Exception ex = Server.GetLastError();
        if (ex is HttpRequestValidationException)
        {
            Server.ClearError();
            Response.Clear();
            Response.StatusCode = 200;

            // add content below
            Response.Write("");
            Response.End();
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 关闭 ServiceStack 日志记录 - Turn Off ServiceStack Logging 关闭日志记录和调试 - Turn off logging and debugging 有没有办法关闭 Hangfire 对 serilog 所做的日志记录? - Is there a way to turn off logging that Hangfire does with serilog? 如何在 Log4net 中关闭特定记录器的日志记录 - How to turn off logging for a specific logger in Log4net 如何关闭由 ASP.NET 核心框架完成的日志记录 - How to turn off the logging done by the ASP.NET core framework log4net:如何关闭程序集引用的日志记录? - log4net: How to turn off logging of an assembly reference? Azure Function v4 - 如何关闭主机日志记录 - Azure Function v4 - How Turn Off Host Logging 是否可以打开/关闭.net核心中的日志记录功能,特别是serilog(将数据记录到.txt文件中) - Is there a to turn on/off the logging functionality in .net core specially the serilog(logging data into .txt file) 如何从 Blazor 中的 HttpClients 关闭浏览器控制台中的“信息”登录? - How can I turn off "info" logging in browser console from HttpClients in Blazor? 如何关闭日志级别和类别 output 中的 .NET Core 日志记录到 AWS CloudWatch? - How can I turn off log level & category output in .NET Core logging to AWS CloudWatch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM