Roles.Enabled 属性

定义

获取或设置用来指示是否为当前 Web 应用程序启用角色管理的值。

public:
 static property bool Enabled { bool get(); };
public:
 static property bool Enabled { bool get(); void set(bool value); };
public static bool Enabled { get; }
public static bool Enabled { get; set; }
member this.Enabled : bool
member this.Enabled : bool with get, set
Public Shared ReadOnly Property Enabled As Boolean
Public Shared Property Enabled As Boolean

属性值

Boolean

如果启用了角色管理,则为 true;否则为 false。 默认值为 false

示例

以下示例演示 ASP.NET 应用程序的 Web.config 文件中的 roleManager 元素system.web。 它指定应用程序使用 SqlRoleProvider 实例并将属性设置为 enabled true

<roleManager defaultProvider="SqlProvider"
  enabled="true"
  cacheRolesInCookie="true"
  cookieName=".ASPROLES"
  cookieTimeout="30"
  cookiePath="/"
  cookieRequireSSL="false"
  cookieSlidingExpiration="true"
  cookieProtection="All" >
  <providers>
    <add
      name="SqlProvider"
      type="System.Web.Security.SqlRoleProvider"
      connectionStringName="SqlServices"
      applicationName="MyApplication" />
  </providers>
</roleManager>

适用于

另请参阅