AuthorizationRuleCollection.Add(AuthorizationRule) メソッド

定義

AuthorizationRule オブジェクトをコレクションに追加します。

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)

パラメーター

rule
AuthorizationRule

コレクションに追加する AuthorizationRule オブジェクト。

例外

AuthorizationRule オブジェクトが既にコレクションに存在している、またはコレクションが読み取り専用です。

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)

注釈

コレクションには、追加するオブジェクトが AuthorizationRule 含まれていない必要があります。

適用対象

こちらもご覧ください