Export (0) Print
Expand All

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.

<healthMonitoring>
    <rules>
        <add name="All Errors Default"
            eventName="All Errors"
            provider="EventLogProvider"
            profile="Default"
            minInterval="00:01:00" 
        />
        <add name="All Audits Default"
            eventName="All Audits"
            provider="SqlWebEventProvider"
            profile="Default"
            minInterval="00:00:30" 
        />
        <add name="Failure Audits Default"
            eventName="Failure Audits"
            provider="WmiWebEventProvider"
            profile="Critical"
            minInterval="00:00:30" 
        />
        <add name="Request Processing Errors"
            eventName="Request Processing Errors"
            provider="CriticalMailEventProvider"
            profile="Default"
        />
        <add name="Infrastructure Notifications"
            eventName="Infrastructure Errors"
            provider="CriticalMailEventProvider"
            profile="Critical"
        />
   </rules>
</healthMonitoring>

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";
healthMonitoringSection.Rules.Add(ruleSetting);

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
Console.WriteLine(
    "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

Community Additions

ADD
Show:
© 2014 Microsoft