MachineKeyCompatibilityMode MachineKeyCompatibilityMode MachineKeyCompatibilityMode MachineKeyCompatibilityMode Enum


指定可使用哪个加密方法。Specifies which encryption methods can be used.

public enum class MachineKeyCompatibilityMode
public enum MachineKeyCompatibilityMode
type MachineKeyCompatibilityMode = 
Public Enum MachineKeyCompatibilityMode


Framework20SP1 Framework20SP1 Framework20SP1 Framework20SP1 0

使用在 2.0 Service Pack 2 以前的 .NET Framework 版本中实现的加密方法。Use the encryption methods that were implemented in .NET Framework versions earlier than version 2.0 Service Pack 2. 初始化向量 (IVs) 针对除了在 ASP.NET 成员资格数据库中存储加密密码外的所有加密操作使用。Initialization vectors (IVs) are used for all encryption operations except for storing encrypted passwords in the ASP.NET membership database.

Framework20SP2 Framework20SP2 Framework20SP2 Framework20SP2 1

使用 .NET Framework 版本 2.0 SP2 和更新版本中可用的强悍加密方法。Use the stronger encryption methods that are available in .NET Framework version 2.0 SP2 and later versions. 初始化向量 (IVs) 针对所有加密操使用。Initialization vectors (IVs) are used for all encryption operations.

Framework45 Framework45 Framework45 Framework45 2

使用 .NET Framework 版本 4.5 和更新版本中可用的加密方法。Use encryption methods that are available in .NET Framework version 4.5 and later versions. 用于 Framework20SP1Framework20SP2的加密方法比较,由默认加密例程生成的密码文本为一个较小的,并针对理论攻击的某些类更可靠。Compared to the encryption methods that are used for Framework20SP1 and Framework20SP2, the ciphertext that is generated by the default cryptographic routines is slightly smaller and is more resilient against certain classes of theoretical attacks. 它们还集成 Windows 8Windows 8 目录中密钥管理以获取所需的加密密钥。They also integrate with Windows 8Windows 8 directory key management in order to get required cryptographic keys. 此操作可让您通过派生自 DataProtector 的类写入和在 DataProtectorType 属性中指定类指类名称来指定自定义加密例程。This option also enables you to specify custom cryptographic routines by writing a class that derives from DataProtector and specifying the class name in the DataProtectorType property.

以下配置要求应用于该选项:The following configuration requirements apply to this option: 1.1. 如果 DataProtectorType 属性有值,则 ApplicationName 属性必须有值。If the DataProtectorType property has a value, the ApplicationName property must also have a value.

2.2. Validation 特性必须从 KeyedHashAlgorithm 类中指定一个系统定义的验证算法 (例如 MD5、 SHA1、 HMACSHA256、 HMACSHA384 或 HMACSHA512) 或一个类中的自定义验证算法。The Validation attribute must specify a system-defined validation algorithm (such as MD5, SHA1, HMACSHA256, HMACSHA384, or HMACSHA512) or a custom validation algorithm in a class that derives from the KeyedHashAlgorithm class. AES 和 3DES 不是验证算法的值。The values AES and 3DES are not validation algorithms.

当指定此选项时,不管使不使用为 Protection 属性指定的值,总是对 Forms 身份验证票进行加密和签名。When you specify this option, forms authentication tickets are always both encrypted and signed, regardless of the value specified for the Protection property. 如果页的 EnableViewStateMac 属性是 trueViewStateEncryptionMode 属性是 Always,则也对视图状态进行加密和签名。View state is also both encrypted and signed if a page's EnableViewStateMac property is true or the ViewStateEncryptionMode property is Always.


设置属性时MachineKeyCompatibilityMode使用这些值。 CompatibilityModeYou use the MachineKeyCompatibilityMode values when you set the CompatibilityMode property.