AuthorizationRule.Action 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 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
属性值
示例
下面的代码示例演示如何使用此属性。
// 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)
注解
在运行时,授权模块会循环 allow
访问和 deny
元素,直到找到适合特定用户的第一个访问规则。 然后,它根据找到 allow
的第一个访问规则是还是 deny
拒绝对 URL 资源的访问权限。 默认情况下允许访问。