共用方式為


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

其中一個 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 的保護,您可能也想要將 CookieRequireSSL 屬性設定為 true

如果您想要資料驗證和加密來協助保護 Cookie,請務必使用此屬性的預設值。 此選項使用已設定的資料驗證演算法。 三重 DES (3DES) 用於加密,如果可用且金鑰夠長 (48 個位元組以上)。

適用於