I have the following error:
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.
http://go.microsoft.com/fwlink/?LinkID=314055
Then I follow that link to find out, what is the problem. Based on that link, the 1st resolution for that problem is Create an explicit element. Which is better to generate from PowerShell. I am trying to run the script from windows powershell, but don't know where's the result after I copy and paste that script into powershell screen.
There are some resolution to fix this error message. I have two questions:
1. Where is the machineKey that has been generate from Powershell? I couldn't find the result.
2. Does anybody know how to fix this error?
Thank you.
You can set the machineKey at the WEBROOT, which is what you probably want for a web server farm, with the following
c:/Windows/System32/inetsrv/Appcmd.exe set config /section:machineKey /commit:WEBROOT /decryptionKey:$dk /validationKey:$vk
Where $dk is the decryptionKey you want and $vk is the validationKey you want. IIS must be installed on your server for inetsrv/appcmd.exe to exist.
You can generate a decryptionKey and validationKey by following Noah Sparks' answer and copy/pasting the results, and so long as the servers you want to be associated with eachother have the same keys you're golden. I would recommend applying a different set of keys per farm though, even if its for the same product in two different domains.
You can also read the keys programatically with
c:\Windows\System32\inetsrv\Appcmd.exe list /commit:WEBROOT config /section:machineKey
Which might come in handy for troubleshooting.
As an aside, I use a configuration management tool (Chef, in this case) and read the keys from an external data source so I don't have to worry about any fat fingering or brain farts and have an audit trail.