AuthorizationSection.Rules Property

Definition

public:
 property System::Web::Configuration::AuthorizationRuleCollection ^ Rules { System::Web::Configuration::AuthorizationRuleCollection ^ get(); };
[System.Configuration.ConfigurationProperty("", IsDefaultCollection=true)]
public System.Web.Configuration.AuthorizationRuleCollection Rules { get; }
[<System.Configuration.ConfigurationProperty("", IsDefaultCollection=true)>]
member this.Rules : System.Web.Configuration.AuthorizationRuleCollection
Public ReadOnly Property Rules As AuthorizationRuleCollection

Property Value

Gets the AuthorizationRuleCollection of AuthorizationRule rules defined by the AuthorizationSection.

Attributes

Examples

The following code example shows how to use the Rules.

 // Using the AuthorizationRuleCollection Add method.

 // Set the action property.
 authorizationRule.Action = 
    AuthorizationRuleAction.Allow;
 // Define the new rule to add to the collection.
 authorizationRule.Users.Add("userName");
 authorizationRule.Roles.Add("admin");
 authorizationRule.Verbs.Add("POST");

 // Add the new rule to the collection.
 authorizationSection.Rules.Add(authorizationRule);
' Using the AuthorizationRuleCollection Add method.
' Set the action property.
  authorizationRule.Action = _
  AuthorizationRuleAction.Allow
' Define the new rule to add to the collection.
authorizationRule.Users.Add("userName")
authorizationRule.Roles.Add("admin")
authorizationRule.Verbs.Add("POST")

' Add the new rule to the collection.
authorizationSection.Rules.Add(authorizationRule)

Remarks

The Rules collection returned by this method does not refer to any actual element in the underlying configuration file. It is a construct that allows easy access to the rules it contains. This is a common pattern for handling the elements of a configuration file.

Applies to

See also