AuthorizationRuleCollection.Add(AuthorizationRule) Methode

Definition

Fügt der Auflistung ein AuthorizationRule Objekt hinzu.

public:
 void Add(System::Web::Configuration::AuthorizationRule ^ rule);
public void Add(System.Web.Configuration.AuthorizationRule rule);
member this.Add : System.Web.Configuration.AuthorizationRule -> unit
Public Sub Add (rule As AuthorizationRule)

Parameter

rule
AuthorizationRule

Das AuthorizationRule Objekt, das der Auflistung hinzugefügt werden soll.

Ausnahmen

Das AuthorizationRule Objekt ist bereits in der Auflistung vorhanden, oder die Auflistung ist schreibgeschützt.

Beispiele

Das folgende Codebeispiel zeigt, wie die Add Methode verwendet wird.

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

Hinweise

Die Auflistung darf nicht bereits das Objekt enthalten, das AuthorizationRule Sie hinzufügen.

Gilt für:

Weitere Informationen