FormsProtectionEnum 枚举

定义

定义要用于 Cookie 的加密类型(如果存在加密类型)。

public enum class FormsProtectionEnum
public enum FormsProtectionEnum
type FormsProtectionEnum = 
Public Enum FormsProtectionEnum
继承
FormsProtectionEnum

字段

All 0

指定应用程序使用数据验证和加密来保护 Cookie。 此选项使用已配置的数据验证算法(基于 machineKey 元素)。 Triple-DES (3DES) 用于加密,条件是它可用且密钥长度至少为 48 个字节。 All 是默认(推荐)值。

Encryption 2

指定使用 Triple-DES 或 DES 加密 Cookie,但不对 Cookie 执行数据验证。 以这种方式使用的 Cookie 可能会遭到所选择的明文安全性攻击。

None 1

指定对仅将 Cookie 用于个性化设置且安全要求较低的站点禁用加密和验证。 建议不要以此方式使用 Cookie;但它对于使用 .NET Framework 实现个人化却是一种消耗资源程度最低的方法。

Validation 3

指定该应用程序使用验证方案来验证已加密的 Cookie 的内容在传输中未被更改。 Cookie 的创建方式是:将验证密钥与 Cookie 数据连接在一起,计算消息身份验证代码 (MAC),然后将 MAC 追加到输出 Cookie 中。

示例

以下示例演示如何使用 FormsProtectionEnum 枚举。 请参阅 类中的 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

注解

如果选择值 All ,系统会根据 machineKey 标记使用配置的数据验证算法。 这是默认值和建议的值。

如果选择 None,Cookie 可能会受到纯文本攻击。

Validation如果选择 ,则通过使用 Cookie 验证创建 Cookie,方法是将验证密钥与 Cookie 数据连接在一起, (MAC) 计算消息身份验证代码,并将 MAC 追加到传出 Cookie。

适用于

另请参阅