Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster
some general errors you may face , when you earn dedicated server with windows server and host your website applications on IIS service is
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Why i’m seeing Validation of viewstate MAC failed
This kind of errorr caused by aps.net worker process or by server IIS recycling the process.The natur of ASP.NET process is to ecncrypt the viewstate by using Autogenerated Key when the process spins up ,The problem comes when a client (browser) sends the request with a viewstate encrypted with the key generated by another worker process. Since the key is different, ASP.NET will not be able to decrypt the viewstate and it will throw the above error.
How to solve ASP.NET Validation of viewstate MAC failed
there are several steps or options that you maight workarround to solve the issue
- Host your site on a server where the application pools never recycle! Obviously, this is impossible.
- Disable ViewstateMac by putting this “enableViewStateMac=”false“” in your web.config on Pages tag under system.web tag. Please note that this step is not 100% secure “and NOT recommended”.
- Configure ASP.NET to not use Auto-Generated Key but rather a predefined key. This is the perfect and secure method.
- To do So please refere to Microsoft article How to create keys and Generate the hashes
and then your web.config should like
2,840 total views, 5 views today