語言

RoleManagerSection.CookieProtection 屬性

定義

取得或設定用於保護快取角色名稱的 Cookie 的安全類型。

public:
 property System::Web::Security::CookieProtection CookieProtection { System::Web::Security::CookieProtection get(); void set(System::Web::Security::CookieProtection value); };
[System.Configuration.ConfigurationProperty("cookieProtection", DefaultValue=System.Web.Security.CookieProtection.All)]
public System.Web.Security.CookieProtection CookieProtection { get; set; }
[<System.Configuration.ConfigurationProperty("cookieProtection", DefaultValue=System.Web.Security.CookieProtection.All)>]
member this.CookieProtection : System.Web.Security.CookieProtection with get, set
Public Property CookieProtection As CookieProtection

屬性值

在 Cookie 中快取角色名稱時所採用的安全保護類型。 預設值為 All。

屬性

範例

以下程式碼範例示範如何使用該 CookieProtection 屬性。 此程式碼範例是本類別更大範例 RoleManagerSection 的一部分。

// Display CookieProtection property.
Console.WriteLine("CookieProtection: {0}",
  configSection.CookieProtection);
' Display CookieProtection property.
Console.WriteLine("CookieProtection: {0}", _
 configSection.CookieProtection)

備註

該 CookieProtection 屬性描述了 Cookie 中資訊如何被安全地儲存。 你可以在 ASP.NET 應用程式的 Web.config 檔案中設定 cookieProtection Cookie 的安全性類型,來指定角色快取的 Cookie 類型。 屬性 cookieProtection 的 CookieProtection 枚舉值為 All、 Encryption、 None或 Validation。 預設值為 All。 如果你想要資料驗證和加密,務必使用該屬性的預設值 CookieProtection 來保護 Cookie。 為了提升 Cookie 的保護,你也可以將屬性設 CookieRequireSSL 為 true。

適用於

另請參閱