• Publisert
  • 1 min

Validation of viewstate MAC failed

<p>A blog post to explain the Validation of viewstate MAC failed error</p>

I have just spent too much time trying to find out why the EPiServer CMS solution I was working on crashed with the error message:
"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."

I got the problem in an EPiServer Enterprise installation in a load balanced environment. And yes, I did follow all the instructions in the "Configuring EPiServer CMS 5 Enterprise". But, there are some missing information in that tech note...  So I decided to write this blog post to help others from spending hours trying to find a solution.

The reason you get the error is actually caused by ASP.NET and not EPiServer, and that is why do not find anything about it in the EPiServer installation documentation. But, the EPiServer cache mechanism in load balanced environments rely on the machineKey setting, so to make your EPiServer sites work, you need to deal with it :) The machineKey is not defined when you install a Windows server, so you need to generate it yourself. You define it in your machine.config file, and you can read more about it here:

In the end, your machineKey should look something like this:
<machineKey validationKey="xxxxx" decryptionKey="yyyy" validation="SHA1"/>
And make sure you use the same key on all the servers in your load balanced environment.