This documentation is archived and is not being maintained.

RuleSettings Class

Configures the ASP.NET event rules. This class cannot be inherited.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

public sealed class RuleSettings : ConfigurationElement

Event rules determine which event, using which profile, is fired to which provider.

The following configuration file excerpt shows how to declaratively specify the properties of the RuleSettings class.

        <add name="All Errors Default"
            eventName="All Errors"
        <add name="All Audits Default"
            eventName="All Audits"
        <add name="Failure Audits Default"
            eventName="Failure Audits"
        <add name="Request Processing Errors"
            eventName="Request Processing Errors"
        <add name="Infrastructure Notifications"
            eventName="Infrastructure Errors"

The following code example shows how to create and set the values of the RuleSettings type. This code example is part of a larger example provided for the HealthMonitoringSection class.

// Add a RuleSettings object to the Rules collection property.
RuleSettings ruleSetting = new RuleSettings("All Errors Default",
    "All Errors", "EventLogProvider");
ruleSetting.Name = "All Errors Custom";
ruleSetting.EventName = "All Errors";
ruleSetting.Provider = "EventLogProvider";
ruleSetting.Profile = "Custom";
ruleSetting.MaxLimit = Int32.MaxValue;
ruleSetting.MinInstances = 1;
ruleSetting.MinInterval = TimeSpan.Parse("00:00:30");
ruleSetting.Custom = "MyEvaluators.MyCustomeEvaluator2, MyCustom.dll";

The following code example shows how to get and display the values of the RuleSettings type. This code example is part of a larger example provided for the HealthMonitoringSection class.

// Display contents of the Rules collection property
    "Rules Collection contains {0} values:", healthMonitoringSection.Rules.Count);

// Display all elements. 
for (System.Int32 i = 0; i < healthMonitoringSection.Rules.Count; i++)
ruleSetting = healthMonitoringSection.Rules[i];
string name = ruleSetting.Name;
string eventName = ruleSetting.EventName;
string provider = ruleSetting.Provider;
string profile = ruleSetting.Profile;
int minInstances = ruleSetting.MinInstances;
int maxLimit = ruleSetting.MaxLimit;
TimeSpan minInterval = ruleSetting.MinInterval;
string custom = ruleSetting.Custom;
    string item = "Name='" + name + "', EventName='" + eventName +
        "', Provider =  '" + provider + "', Profile =  '" + profile +
        "', MinInstances =  '" + minInstances + "', MaxLimit =  '" + maxLimit +
        "', MinInterval =  '" + minInterval + "', Custom =  '" + custom + "'";
    Console.WriteLine("  Item {0}: {1}", i, item);

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0