ASP.Net healthMonitoring with AJAX

Currently, in all of our environments, we have enabled the health monitoring feature to alert us when a user causes an error:

<healthMonitoring enabled="true">
  <providers>
    <add name="MailWebEventProvider" type="System.Web.Management.SimpleMailWebEventProvider" to="email@addr.com" from="email@addr.com" buffer="false" subjectPrefix="prefix: "/>
  </providers>
  <rules>
    <add name="All errors from my site" eventName="All Errors" provider="MailWebEventProvider" profile="Critical"/>
  </rules>
</healthMonitoring>

We recently started introducing more AJAX functionality, and I just realized that any error that occurs when a page is partially refreshed does not start the healthmail manager to send emails. The user receives a default warning window (); however nothing is server side.

Does anyone know how to enable this? I'm not sure what settings I am missing

Edit

I see that the ScriptManager control has an event called "AsyncPostBackError". If I take it and throw an e.Exception, it will burn up the health monitor; however, it removes the error that the user sees. Does anyone know how to start a health monitor without causing errors like this?

+3
source share
2 answers

, , , , , , , -, . , , , .

; , -.

+2

, :

protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
{
    ((ScriptManager)sender).AsyncPostBackErrorMessage = e.Exception.Message;

    WebBaseEvent.Raise(new AjaxWebErrorEvent(e.Exception.Message, null, 100123, e.Exception)); 
}

AjaxWebErrorEvent:

public class AjaxWebErrorEvent : WebRequestErrorEvent
{
    public AjaxWebErrorEvent(string message, object eventSource, int eventCode, System.Exception e) 
        : base(message, eventSource, eventCode, e)
    {
    }
}
+2

Source: https://habr.com/ru/post/1709669/


All Articles