AuthorizationSection.Rules 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
property System::Web::Configuration::AuthorizationRuleCollection ^ Rules { System::Web::Configuration::AuthorizationRuleCollection ^ get(); };
[System.Configuration.ConfigurationProperty("", IsDefaultCollection=true)]
public System.Web.Configuration.AuthorizationRuleCollection Rules { get; }
[<System.Configuration.ConfigurationProperty("", IsDefaultCollection=true)>]
member this.Rules : System.Web.Configuration.AuthorizationRuleCollection
Public ReadOnly Property Rules As AuthorizationRuleCollection
属性值
获取由 AuthorizationRuleCollection 定义的 AuthorizationRule 规则的 AuthorizationSection。
- 属性
示例
下面的代码示例演示如何使用 .Rules
// 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)
注解
Rules此方法返回的集合不引用基础配置文件中的任何实际元素。 它是一个构造,允许轻松访问它包含的规则。 这是用于处理配置文件元素的常见模式。