Roles.CookieProtectionValue 屬性

定義

取得值,表示如何保護在 Cookie 中快取的角色名稱。

public:
 static property System::Web::Security::CookieProtection CookieProtectionValue { System::Web::Security::CookieProtection get(); };
public static System.Web.Security.CookieProtection CookieProtectionValue { get; }
static member CookieProtectionValue : System.Web.Security.CookieProtection
Public Shared ReadOnly Property CookieProtectionValue As CookieProtection

屬性值

其中一個 CookieProtection 列舉值,表示如何保護在 Cookie 中快取的角色名稱。 預設為 All

範例

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

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

備註

您可以在 ASP.NET 應用程式的 Web.config 檔案中設定 cookieProtection 屬性,以指定應用程式快取角色的 Cookie 保護。 屬性 cookieProtection 會採用 CookieProtection 列舉值,指出角色名稱是否已加密、驗證、兩者或兩者皆未加密。

適用於

另請參閱