Aracılığıyla paylaş


AuthorizationRuleCollection.Add(AuthorizationRule) Yöntem

Tanım

Koleksiyona bir AuthorizationRule nesne ekler.

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)

Parametreler

rule
AuthorizationRule

AuthorizationRule Koleksiyona eklenecek nesne.

Özel durumlar

AuthorizationRule Nesnesi koleksiyonda zaten var veya koleksiyon salt okunur.

Örnekler

Aşağıdaki kod örneğinde yönteminin nasıl kullanılacağı gösterilmektedir Add .

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

Açıklamalar

Koleksiyon, eklediğiniz nesneyi zaten içermemelidir AuthorizationRule .

Şunlara uygulanır

Ayrıca bkz.