Prevent HealthMonitoring error messages for dangerous queries.

Currently, I am monitoring health status for a public site. I use SimpleMailWebEventProvider to send emails when errors occur. "All errors."

I hope that someone who has experience with this can show me a simple way to prevent sending emails in the case of a "Potentially dangerous Request.Path value was detected by the client (:)" I can see these errors and I can say that they come from the bot, and not from the person, in time (all at once) and at the requested URL

Example:

Request path: /Scripts/,data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g

I like the fact that .Net throws an error in these cases, but these emails probably account for 90% of all the messages I receive from health monitoring. Reading all of them to find error messages that indicate a problem with the code on the website is a hassle.

I would like not to create my own MailEventProvider, although I was in the past, but I believe that I had to use ILSpy to create my own, since SimpleMailWebEventProvider is Sealed.

+5
source share
1 answer

, , Server.ClearError() Application_Error Global.asax, . , , .

void Application_Error(object sender, EventArgs e)
{
    var exception = Server.GetLastError();
    if (exception is HttpException && exception.Message.Contains("A potentially dangerous Request.Path value was detected from the client"))
    {
        Server.ClearError();
    }
}

, , , , , , IP-, URL- ..

+8

All Articles