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 的保护,你可能还希望将 CookieRequireSSL 属性设置为 true

如果希望数据验证和加密都有助于保护 Cookie,请务必使用此属性的默认值。 此选项使用配置的数据验证算法。 Triple-DES(3DES)用于加密(如果可用),如果密钥足够长(48 字节或更多)。

适用于