Web events can contain information about the ASP.NET worker process, application domain, request data, response data, application errors, and configuration errors. The following managed Web event classes are available in ASP.NET as members of the System.Web.Management namespace. All event classes inherit from the WebBaseEvent base class. For information about how to obtain event data, see Consuming Web Events Using Event Providers later in this topic.
Event class | Description |
|---|
WebApplicationLifetimeEvent | Represents a significant event in the lifetime of an ASP.NET application. Application lifetime events include events such as application startup and shutdown events. If an application is terminated, you can determine why by viewing the related event-message field. |
WebAuditEvent | Serves as the base class for all ASP.NET health-monitoring audit events. |
WebAuthenticationFailureAuditEvent | Provides information about ASP.NET authentication failures. |
WebAuthenticationSuccessAuditEvent | Provides information about successful authentication events. |
WebBaseErrorEvent | Serves as the base class for all the health-monitoring error events. |
WebBaseEvent | Serves as the base class for the ASP.NET health-monitoring events. |
WebErrorEvent | Provides information about errors caused by problems with configuration or application code. An example is the error issued by ASP.NET when an error is found in a page. |
WebFailureAuditEvent | Provides information about security failures. |
WebHeartbeatEvent | Serves as a timer for the ASP.NET health-monitoring system. These events are raised at an interval defined by the heartbeatInterval attribute of the healthMonitoring configuration section. |
WebManagementEvent | Serves as the base class for events that carry application and process information. |
WebRequestErrorEvent | Defines the event that carries information about Web-request errors. |
WebRequestEvent | Serves as the base class for events providing Web-request information. |
WebSuccessAuditEvent | Provides information about successful security events. An example of this is a successful URL authorization for a Web request. |
WebViewStateFailureAuditEvent | Provides Web-application view state failure information. |
By default, ASP.NET automatically records some Web event data. For example, some event data, such as the number of times that an event occurs, is captured using performance counters. In these situations, performance counters are used instead of Web events to minimize the impact on the performance of health-monitored applications. This behavior is not customizable. For more information, see ASP.NET Performance, performance counters, and the Performance monitoring pages in MSDN.
Customizing Events
You can customize Web events in the following ways:
You can limit the number of event notifications that occur in a given time span and specify the interval between events using attributes of the rules element. The following example shows a fragment from the configuration file in which the Default profile is configured for Failure Audit events. The Default profile specifies the following settings
The minimum number of times an event can occur before an event notification is sent is 1.
The maximum number of times an event can occur before notifications stop is 2147483647 (infinite).
The minimum time interval between two events is one minute.
|
<rules>
<add
name="Failure Audits Default"
eventName="Failure Audits"
provider="EventLogProvider"
profile="Default"
minInstances="1" maxLimit="Infinite" minInterval="00:01:00"
custom=""
/>
<!-- additional <add> elements here -->
</rules> |
You can subscribe an existing provider or a custom provider to a Web event by configuring a new rules element in your Web.config file. The following example code shows how the EventLogWebEventProvider subscribes to a custom event named SampleCustomWebEvent. The EventLogProvider is already configured in the root Web.config file.
|
<rules>
<add
name="Sample Custom Events"
eventName="SampleCustomWebEvent"
provider="EventLogProvider"
profile="Default"
minInstances="1"
maxLimit="Infinite"
minInterval="00:01:00"
custom=""
/>
</rules>
<eventMappings>
<add
name="SampleCustomWebEvent"
type="Microsoft.Samples.Web.Management.SampleCustomWebEvent"
startEventCode="0"
endEventCode="2147483647"
/>
</eventMappings> |
If none of the built-in event classes meets your needs, you can create custom events by inheriting from existing event classes. For more information, see Extending ASP.NET Health Monitoring.
Note: |
|---|
Do not place the source code that you create for custom event providers and custom Web events in the App_Code directory. Instead, compile the source code into assemblies and place those assemblies in the Bin directory. For more information on application folders, see ASP.NET Web Site Layout. |