Share via


AuthorizationSection.Rules Propiedad

Definición

Obtiene la colección AuthorizationRuleCollection de reglas AuthorizationRule.

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

Valor de propiedad

Obtiene la colección AuthorizationRuleCollection de reglas AuthorizationRule definida por AuthorizationSection.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar 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)

Comentarios

La Rules colección devuelta por este método no hace referencia a ningún elemento real del archivo de configuración subyacente. Es una construcción que permite un fácil acceso a las reglas que contiene. Se trata de un patrón común para controlar los elementos de un archivo de configuración.

Se aplica a

Consulte también