Prevent HealthMonitoring to send email for specific error RRS feed

  • Question

  • User-1956618660 posted

    I set up healthmonitoring in web.config to send email for unhandled exception and it's working fine.

    I want to prevent it to send email for a certain specific error.

    I put in global.asax the following code:

    protected void Application_Error(Object sender, EventArgs e)
            System.Exception exc = Context.Server.GetLastError();
            if (exc.Message.Contains("my error message"))

    That I thought it'd block email, but I still receiving it.

    I know (by debug) that Server.ClearError() is executed.

    Maybe I'm missing something.... Can anybody help?

    Monday, November 4, 2013 6:21 AM


  • User-166373564 posted

    Hi marco_ked

    You could take a look at this article to learn how to add Custom Error Page in ASP.NET application,

    1.  Configuring error at the page level:

    //This block will execute when there any error on the page and we can fetch the current context
      HttpContext context = HttpContext.Current;
      //This block will fetch current excpetion
      Exception exception = context.Server.GetLastError();
      //This block will write the custom error message on the page
      //This will clear the error from the server and let the page finish

    2. Configuring error at the application level.

    3. Configuring error from configuration.


    I think these methods are also available for you, please have a try on your side.

    Best regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 6, 2013 10:13 PM