MachineKeyValidation Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies the hashing algorithm that ASP.NET uses for forms authentication and for validating view state data, and for out-of-process session state identification.
public enum class MachineKeyValidation
public enum MachineKeyValidation
type MachineKeyValidation =
Public Enum MachineKeyValidation
- Inheritance
Fields
Name | Value | Description |
---|---|---|
MD5 | 0 | Specifies that ASP.NET uses the Message Digest 5 ( |
SHA1 | 1 | Specifies that ASP.NET uses the |
TripleDES | 2 | Specifies that ASP.NET uses the TripleDES ( |
AES | 3 | Specifies that ASP.NET uses the If you choose this option, the DecryptionKey property will be used for encryption and decryption, and the |
HMACSHA256 | 4 | Specifies that ASP.NET uses the |
HMACSHA384 | 5 | Specifies that ASP.NET uses the |
HMACSHA512 | 6 | Specifies that ASP.NET uses the |
Custom | 7 | Specifies that ASP.NET uses a custom hashing algorithm. The custom hashing algorithm can be implemented in any class that derives from KeyedHashAlgorithm. The custom algorithm is typically specified declaratively in the |
Examples
The following code example shows how to use the MachineKeyValidation enumeration. In the example, configSection
is an instance of MachineKeySection. This code example is part of a larger example provided for the MachineKeySection class.
// Set Validation property.
configSection.Validation = MachineKeyValidation.HMACSHA256;
' Set Validation value.
configSection.Validation = MachineKeyValidation.HMACSHA256
Remarks
ASP.NET uses a hash-based message authentication code (HMAC) to help detect whether data that is used for forms authentication or view state has been tampered with. The HMAC is generated when view state content is created, and the HMAC is checked on subsequent requests. The HMAC helps ASP.NET determine whether someone has changed data that is sent between the server and the client, but the data can be read by anyone as it travels through the Internet unless it is also encrypted. By default, view state is validated but not encrypted. For more information, see ViewStateEncryptionMode and RegisterRequiresViewStateEncryption.
The MachineKeyValidation
enumeration lets you specify the algorithm that ASP.NET uses to create the HMAC. The default value is HMACSHA256
. ASP.NET uses the value of the ValidationKey property with the selected algorithm to generate the HMAC.