WebBaseEventCollection Class

Contains a collection of WebBaseEvent objects. This class cannot be inherited.

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

public sealed class WebBaseEventCollection : ReadOnlyCollectionBase
public final class WebBaseEventCollection extends ReadOnlyCollectionBase
public final class WebBaseEventCollection extends ReadOnlyCollectionBase
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.

The WebBaseEventCollection class is used to deliver a collection of health-monitoring events to providers such as the SqlWebEventProvider.

The following code example shows how to use the WebBaseEventCollection class.

using System;
using System.Text;
using System.Web;
using System.Web.Management;
using System.Collections;

namespace SamplesAspNet
    // Implements a custom WebBaseEvent class. 
    // Everytime this class is instantiated a WebBaseEvent is 
    // created. This event object is then added to the static 
    // simulatedEvents array list.
    public class SampleWebBaseEventCollection : System.Web.Management.WebBaseEvent
        private string customCreatedMsg;

        private static ArrayList simulatedEvents = new ArrayList();
        private static System.Web.Management.WebBaseEventCollection events;

        // Create a new WebBaseEvent and add it to the 
        // static array list simulatedEvents.
        public SampleWebBaseEventCollection(
        string msg, object eventSource, int eventCode):
        base(msg, eventSource, eventCode)

            customCreatedMsg =
              string.Format("Event created at: {0}", 



        // Get the event with the specified index.
        public static WebBaseEvent GetItem(int index)
            return events[index];

        // Get the index of the specified event.
        public static int GetIndexOf(WebBaseEvent ev)
            return events.IndexOf(ev);

        // Check if the specified event is in the collection.
        public static bool ContainsEvent(WebBaseEvent ev)
            return events.Contains(ev);

        // Create an event collection.
        // Add to it the created simulatedEvents.
        public static void AddEvents()
            events = 
            new System.Web.Management.WebBaseEventCollection(

        // Display the events contained in the collection.
        public override void FormatCustomEventDetails(WebEventFormatter formatter)
            // Add custom data.

            formatter.IndentationLevel += 1;
                "**SampleWebBaseEventCollection Data Start **");
            foreach (WebBaseEvent ev in events)
                    "Message:   {0}", ev.Message));
                    "Source:    {0}", ev.EventSource.ToString()));
                    "Code:      {0}", ev.EventCode.ToString()));

                "**SampleWebBaseEventCollection Data End **");

            formatter.IndentationLevel -= 1;




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