AuthorizationRuleCollection.Add(AuthorizationRule) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a AuthorizationRule object to the collection.
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)
Parameters
- rule
- AuthorizationRule
The AuthorizationRule object to add to the collection.
Exceptions
The AuthorizationRule object already exists in the collection, or the collection is read-only.
Examples
The following code example shows how to use the Add method.
// 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)
Remarks
The collection must not already contain the AuthorizationRule object you are adding.
Applies to
See also
Colabore connosco no GitHub
A origem deste conteúdo pode ser encontrada no GitHub, onde também pode criar e rever problemas e pedidos Pull. Para mais informações, consulte o nosso guia do contribuidor.