AnonymousIdentificationSection.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.Validation)]
public System.Web.Security.CookieProtection CookieProtection { get; set; }
[<System.Configuration.ConfigurationProperty("cookieProtection", DefaultValue=System.Web.Security.CookieProtection.Validation)>]
member this.CookieProtection : System.Web.Security.CookieProtection with get, set
Public Property CookieProtection As CookieProtection

屬性值

這是其中一項 CookieProtection 價值。 預設值為 All

屬性

範例

以下程式碼範例說明如何存取該 CookieProtection 物業。

// Get CookieProtection.
System.Web.Security.CookieProtection cookieProtection =
    anonymousIdentificationSection.CookieProtection;
Console.WriteLine("Cookie protection: {0}",
           cookieProtection);
' Get CookieProtection.
Dim cookieProtection _
As System.Web.Security.CookieProtection = _
anonymousIdentificationSection.CookieProtection
Console.WriteLine( _
"Cookie protection: {0}", cookieProtection)

備註

為了提升 Cookie 的安全性,你也可以將屬性設 CookieRequireSSLtrue

如果你想要同時進行資料驗證和加密,請務必使用這個屬性的預設值來保護 Cookie。 此選項使用已設定的資料驗證演算法。 Triple-DES(3DES)用於加密,前提是有且金鑰長度足夠(48 位元組或以上)。

適用於