AuthorizationSection.Rules Property

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

[ConfigurationPropertyAttribute("", IsDefaultCollection = true)]
public AuthorizationRuleCollection Rules { get; }

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.

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);

.NET Framework
Available since 2.0
Return to top
Show: