How to resolve Validation of ViewState MAC failed?


What is ViewState in

View State is the method to preserve the Value of the Page and Controls between round trips between WebForms (.aspx) pages in an T. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.


What causes MAC validation errors?

1) The machine key is not added/updated for the domain.

If the website applications are running without updating MAC or Machine Key on ASP.NET Project ‘web.config’ file the domain will through a MAC validation failure error. However, because this auto-generated key is local to Windows VPS Server Hosting or Cloud server that created the key causing on the server.


2) The web application is running on a farm.

This auto-generated key is used if there is no explicit <machineKey> element in the application’s configuration. The ASP.NET automatically generates a cryptographic key for each application and stores the key in the HKCU registry hive. This scenario causes a problem for applications that run on a farm.


3) The worker process uses the IIS 7.0 application pool identity

Internet Information Services (IIS) introduced application pool identity, a new isolation mechanism that helps provide increased security for servers that run ASP.NET applications in a shared web hosting environment.  The sites that are running under the application pool identity do not have access to the HKCU registry.


4) The application pool is configured by using LoadUserProfile=false

If the application pool is running with a custom identity, IIS may not have loaded the user profile for the identity. Therefore, verify the website application pool and make the changes.


9571 Save 44%
5360 / month
7.4 / hour
  • Disk Space : 80 GB SSD
  • 4 Core
  • RAM : 8 GB
  • Bandwidth : 5 TB
6929 Save 44%
3880 / month
5.3 / hour
  • Disk Space : 80 GB SSD
  • 2 Core
  • RAM : 6 GB
  • Bandwidth : 5 TB
4786 Save 44%
2680 / month
3.7 / hour
  • Disk Space : 60 GB SSD
  • 2 Core
  • RAM : 4 GB
  • Bandwidth : 4 TB
19214 Save 44%
10760 / month
14.9 / hour
  • Disk Space : 120 GB SSD
  • 8 Core
  • RAM : 16 GB
  • Bandwidth : 6 TB
38286 Save 44%
21440 / month
29.7 / hour
  • Disk Space : 320 GB SSD
  • 12 Core
  • RAM : 32 GB
  • Bandwidth : 7 TB
2545 Save 44%
1425 / month
1.9 / hour
  • Disk Space : 50 GB SSD
  • 2 Core
  • RAM : 2 GB
  • Bandwidth : 3 TB




We used IIS as domain machineKey generator to resolve the issue:

1. Open IIS and select a website to get this screen:


2. Double click the Machine Key icon to get this screen:




3. Click "Generate Keys" link on the right which I outlined in the Image above.



4. Once the Keys Generated click “Apply” to update the key on your website.

The Generated code will be auto saved in your web.config file. If not updated don't forget to change the validation property on machineKey in the web.config file.