AuthorizationSection.Rules Propriété

Définition

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

Valeur de propriété

Obtient les AuthorizationRuleCollectionAuthorizationRule règles définies par le AuthorizationSection.

Attributs

Exemples

L’exemple de code suivant montre comment utiliser le 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)

Remarques

La Rules collection retournée par cette méthode ne fait référence à aucun élément réel dans le fichier de configuration sous-jacent. Il s’agit d’une construction qui permet un accès facile aux règles qu’il contient. Il s’agit d’un modèle courant pour gérer les éléments d’un fichier de configuration.

S’applique à

Voir aussi