WmiWebEventProvider Class

Implements an event provider that maps ASP.NET health-monitoring events to Windows Management Instrumentation (WMI) events.

Namespace: System.Web.Management
Assembly: System.Web (in system.web.dll)

Public Class WmiWebEventProvider
	Inherits WebEventProvider
Dim instance As WmiWebEventProvider

public class WmiWebEventProvider extends WebEventProvider
public class WmiWebEventProvider extends WebEventProvider
Not applicable.

ASP.NET health monitoring allows production and operations staff to manage deployed Web applications. The System.Web.Management namespace contains the health-event types responsible for packaging application health-status data and the provider types responsible for processing this data. It also contains supporting types that help during the management of health events.

ASP.NET uses this class to map health-monitoring events to WMI events. To enable the delivery of ASP.NET health-monitoring events to the WMI subsystem, you must configure the WmiWebEventProvider class by adding the appropriate settings in the <healthMonitoring> section of the configuration file.

The information contained in the Aspnet.mof file describes the parameters of the WMI events raised when ASP.NET health-monitoring events are routed to the WmiWebEventProvider class and mapped into WMI events. The Aspnet.mof file is stored in the .NET Framework build directory, for example %windir%\Microsoft.NET\Framework\BuildNumber. For more information about reporting health-monitoring events as WMI events, see Using WMI to Deliver ASP.NET Health Monitoring Events.


In most cases you will be able to use the ASP.NET health-monitoring types as implemented, and you will control the health-monitoring system by specifying values in the <healthMonitoring> configuration section. You can also derive from the health-monitoring types to create your own custom events and providers. For an example of creating a custom provider, see ASP.NET Health Monitoring Custom Provider Sample.

The following example shows how to create a consumer of WMI events issued by ASP.NET health monitoring as a result of Web-application health events.


The WmiWebEventProvider class and the health event types to monitor are already configured by default. The only thing you need to do is to define the rule for all the health events. Remember that the health events are not dispatched to the WmiWebEventProvider provider by default.

Imports System
Imports System.Management

' Capture WMI events associated with 
' ASP.NET health monitoring types. 

Class SampleWmiWebEventListener
    'Displays event related information.
    Shared Sub DisplayEventInformation(ByVal ev _
As ManagementBaseObject)

        ' It contains the name of the WMI raised 
        ' event. This is the name of the 
        ' event class as defined in the 
        ' Aspnet.mof file.
        Dim eventTypeName As String

        ' Get the name of the WMI raised event.
        eventTypeName = ev.ClassPath.ToString()

        ' Process the raised event.
        Select Case eventTypeName
            ' Process the heartbeat event.  
            Case "HeartBeatEvent"
                Console.WriteLine(vbTab + _
                "Process: {0}", ev("ProcessName"))
                Console.WriteLine(vbTab + "App: {0}", _
                Console.WriteLine(vbTab + "WorkingSet: {0}", _
                Console.WriteLine(vbTab + "Threads: {0}", _
                Console.WriteLine(vbTab + "ManagedHeap: {0}", _
                Console.WriteLine(vbTab + "AppDomainCount: {0}", _

                ' Process the request error event. 
            Case "RequestErrorEvent"
                Console.WriteLine("Url: {0}", _
                Console.WriteLine("Path: {0}", _
                Console.WriteLine("Message: {0}", _
                Console.WriteLine("Stack: {0}", _
                Console.WriteLine("UserName: {0}", _
                Console.WriteLine("ThreadID: {0}", _

                ' Process the application lifetime event. 
            Case "ApplicationLifetimeEvent"
                Console.WriteLine("App Lifetime Event {0}", _

                ' Handle events for which processing is not
                ' provided.
            Case Else
                Console.WriteLine("ASP.NET Event {0}", _
        End Select

    End Sub 'DisplayEventInformation

    ' End DisplayEventInformation.
    ' The main entry point for the application.
    Shared Sub Main(ByVal args() As String)
        ' Get the name of the computer on 
        ' which this program runs.
        ' Note. The monitored application must also run 
        ' on this computer.
        Dim machine As String = Environment.MachineName

        ' Define the Common Information Model (CIM) path 
        ' for WIM monitoring. 
        Dim path As String = _
        String.Format("\\{0}\root\aspnet", machine)

        ' Create a managed object watcher as 
        ' defined in System.Management.
        Dim query As String = "select * from BaseEvent"
        Dim watcher As New ManagementEventWatcher(query)

        ' Set the watcher options.
        Dim timeInterval As New TimeSpan(0, 1, 30)
        watcher.Options = _
        New EventWatcherOptions(Nothing, timeInterval, 1)

        ' Set the scope of the WMI events to 
        ' watch to be ASP.NET applications.
        watcher.Scope = _
        New ManagementScope(New ManagementPath(path))

        ' Set the console background.
        Console.BackgroundColor = ConsoleColor.Blue
        ' Set foreground color.
        Console.ForegroundColor = ConsoleColor.Yellow
        ' Clear the console.

        ' Loop indefinitely to catch the events.
        Console.WriteLine( _
        "Listener started. Enter CntlC to terminate")

        While True
                ' Capture the WMI event related to 
                ' the Web event.
                Dim ev As ManagementBaseObject = _
                ' Display the Web event information.

                ' Prompt the user.

            Catch e As Exception
                Console.WriteLine("Error: {0}", e)
                Exit While
            End Try
        End While

    End Sub 'Main 
End Class 'SampleWmiWebEventListener 

The following example is a configuration file excerpt that shows a <healthMonitoring> configuration section that enables ASP.NET to use the WmiWebEventProvider provider to process all health-monitoring events.


  • AspNetHostingPermission  for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
  • AspNetHostingPermission  for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions