MachineKeyValidation Enumeration
Collapse the table of content
Expand the table of content

MachineKeyValidation Enumeration


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.

Namespace:   System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

public enum MachineKeyValidation

Member nameDescription

Specifies that ASP.NET uses the AES (Rijndael) encryption algorithm.


Specifies that ASP.NET uses a custom hashing algorithm.


Specifies that ASP.NET uses the HMACSHA256 hashing algorithm. This is the default value.


Specifies that ASP.NET uses the HMACSHA384 hashing algorithm.


Specifies that ASP.NET uses the HMACSHA512 hashing algorithm.


Specifies that ASP.NET uses the Message Digest 5 (MD5) hashing algorithm.


Specifies that ASP.NET uses the HMACSHA1 hash algorithm.


Specifies that ASP.NET uses the TripleDES (3DES) encryption algorithm.

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.

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.SHA1;

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft