AuthorizationRuleCollection.Add(AuthorizationRule) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Lägger till ett AuthorizationRule objekt i samlingen.
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)
Parametrar
- rule
- AuthorizationRule
Objektet AuthorizationRule som ska läggas till i samlingen.
Undantag
Objektet AuthorizationRule finns redan i samlingen, eller så är samlingen skrivskyddad.
Exempel
I följande kodexempel visas hur metoden Add används.
// 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)
Kommentarer
Samlingen får inte redan innehålla det objekt som AuthorizationRule du lägger till.