Validation of viewstate MAC failed On Dedicated windows server

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 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

  1. Host your site on a server where the application pools never recycle! Obviously, this is impossible.
  2. 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”.
  3. Configure ASP.NET to not use Auto-Generated Key but rather a predefined key. This is the perfect and secure method.

and then your web.config should like

<machineKey validationKey=”08CE6B478DCE73……….E566D8AC5D1C045BA60″

2,840 total views, 5 views today

Leave a Reply

Your email address will not be published. Required fields are marked *