共用方式為


AuthorizationRule.Action 屬性

定義

取得或設定 AuthorizationRule 動作。

public:
 property System::Web::Configuration::AuthorizationRuleAction Action { System::Web::Configuration::AuthorizationRuleAction get(); void set(System::Web::Configuration::AuthorizationRuleAction value); };
public System.Web.Configuration.AuthorizationRuleAction Action { get; set; }
member this.Action : System.Web.Configuration.AuthorizationRuleAction with get, set
Public Property Action As AuthorizationRuleAction

屬性值

AuthorizationRuleAction

其中一個 AuthorizationRuleAction 值。

範例

下列程式碼範例示範如何使用這個屬性。

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

備註

在執行時間,授權模組會逐一查看 allowdeny 元素,直到找到符合特定使用者的第一個存取規則為止。 然後,它會根據找到的第一個存取規則是 allowdeny ,授與或拒絕 URL 資源的存取權。 預設允許存取。

適用於