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 字节或更长),则使用 3DES 来进行加密。

适用于