Instrument for user management events
Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen
Use ASP.NET health monitoring to Instrument your application and monitor user management events around authentication and authorization.
Doing this helps you to detect and react to potentially suspicious behavior. It also enables you to gather operations data; for example, to track who is accessing your application and when user account passwords need to be reset.
The following steps show how to instrument your application for user management events
- Create a Custom user management web event, by creating a class library and then create a class that inherits from WebAuditEvent.
public class MyEvent : WebAuditEvent
public MyEvent(string msg, object eventSource, int eventCode): base(msg, eventSource, eventCode)
public MyEvent(string msg, object eventSource, int eventCode, int eventDetailCode): base(msg, eventSource, eventCode, eventDetailCode)
public override void FormatCustomEventDetails(WebEventFormatter formatter)
// Display some custom event message
formatter.AppendLine("Some Critical Event Fired");
- Configure your WCF Service for Health Monitoring
<add name="Some Custom Event" type="MyEventLibrary.MyEvent, MyEventLibrary"/>
<add name="Custom event" eventName="Some Custom Event" provider="EventLogProvider" minInterval="00:00:01"/>
- Instrument the WCF Service by raising the custom event in a service contract.
public string InvokeCriticalEvent()
MyEvent obj = new MyEvent("Invoking Some Custom Event", this, WebEventCodes.WebExtendedBase + 1);
return "Critical event invoked";
- Verify the Service Events in the Event Log after calling the service method from a Test client.