FormsAuthenticationConfiguration.Protection 属性

定义

获取或设置用于加密 Cookie 的加密类型。

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

属性值

枚举值之 FormsProtectionEnum 一。 默认值为 All

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

为了改进 Cookie 的保护,你可能还需要将 Cookie true设置为 RequireSSL

属性

示例

下面的代码示例演示如何访问 Protection 属性。 请参阅类主题中的 FormsAuthenticationConfiguration 代码示例,了解如何获取该部分。

// Get the current Protection.
FormsProtectionEnum currentProtection =
    formsAuthentication.Protection;

// Set the Protection property.
formsAuthentication.Protection =
    FormsProtectionEnum.All;
' Get the current Protection.
Dim currentProtection As FormsProtectionEnum =
formsAuthentication.Protection

' Set the Protection property.
formsAuthentication.Protection = FormsProtectionEnum.All

适用于

另请参阅