views:

125

answers:

2

My ASP.NET app has a web.config healthMonitoring section set up to email me when errors occur. Periodically I get errors that I would like to ignore, such as Invalid Viewstate or ScriptResource.axd errors. Is there any way to configure web.config to NOT email me when the exception message matches a certain search string or regex? I thought I've seen this somewhere but my google-fu is failing me.

I believe this is similar to http://stackoverflow.com/questions/618275/asp-net-ignore-healthmonitoring-event-by-eventdetailcode

A: 

You can create a custom event provider by inheriting from the System.Web.Management.WebEventProvider base provider class. This way you could handle the errors you want to by emailing them and ignoring any others. Checkout "How to Write a Custom Web Event Provider for ASP.NET 2.0" and "Creating Custom Event Providers" for more info.

David Glass
A: 

are you raising the events yourself, or are they raised in the background. I would look at the EventCode for the event and see if you can use that to distinguish between this event type and another? If you are raising the event yourself, like in a catch statement, you can easily separate it out. But if you are using the global blanket for catching all errors, there is no way. The only way is to use the event code in eventMapping and then add rules to catch that event and send it to a provider.

wcpro