[英]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.