Share via


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; }
static member Enabled : bool
static member Enabled : bool with get, set
Public Shared ReadOnly Property Enabled As Boolean
Public Shared Property Enabled As Boolean

屬性值

如果已啟用角色管理,則為 true,否則為 false。 預設為 false

範例

下列範例顯示 ASP.NET 應用程式Web.config檔案區段中 的 roleManager 元素 system.web 。 它會指定應用程式使用 SqlRoleProvider 實例,並將 屬性設定 enabledtrue

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

適用於

另請參閱