-2

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.

Haminteu
  • 1,292
  • 4
  • 23
  • 49
  • Are you making any alterations to the DOM in your UI before you post back? *(I assume that if you were running in a web farm, you'd have said, and that this is completely reproducable.)* – Adrian Wragg Sep 08 '14 at 08:39
  • -1 for unclear problem statement. What, exactly, are you running from Powershell? – vonPryz Sep 08 '14 at 08:46
  • @vonPryz, because of this --> There are many web sites that will generate a element for you with the click of a button. Never use a element that you obtained from one of these sites. It is impossible to know whether these keys were created securely or if they are being recorded to a secret database. You should only ever use configuration elements that you created yourself. – Haminteu Sep 09 '14 at 01:54
  • @AdrianWragg, no.. I didn't make it. You said completely reproducable. I didn't get you. – Haminteu Sep 09 '14 at 01:56
  • You are doing *something you don't describe* and then just tell you got an view state error. How, exactly, you think one could help without knowing how and where you got the error message in the first hand? That being said, I guess you are either messing with posting an Asp.Net form or running a poor load balancing setup. Which, I cannot tell. Try start by [reading an article](http://weblogs.asp.net/infinitiesloop/Truly-Understanding-Viewstate) about the view state. – vonPryz Sep 09 '14 at 04:58
  • @vonPryz, very nice article. Thank you. – Haminteu Sep 09 '14 at 06:42
  • @Haminteu Are you trying to solve the Powershell issue, or the viewstate problem? Your question isn't clear, I assumed the latter and that you were getting it consistently. – Adrian Wragg Sep 09 '14 at 08:45
  • @AdrianWragg, Ah, apologize.. Ok, I'll edit my question. – Haminteu Sep 10 '14 at 01:31

2 Answers2

1

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.

JackChance
  • 520
  • 3
  • 11
0

If you have access to IIS where this is occurring, you can open IIS, go to the website and at the top level there is a machine key icon.

Open it, uncheck all the automatic/autogenerate options in the middle section, then on the right hand side hit generate keys > save.

Noah Sparks
  • 1,710
  • 13
  • 14
  • Hi Noah, If I run it from IIS on my development server. Is the machinekey will work on the production server? – Haminteu Sep 09 '14 at 01:57