Avoiding error message : "Validation of viewstate MAC failed."

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hello everyone,

I was browsing the forum and found out that many members often get an error message in the system log of their website:

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

In order to avoid this error - you have to generate and add your own machineKey to web.config file

I found an online machine key generator which i would like to share with you guys :
http://aspnetresources.com/tools/machineKey (You just have to press "Generate Key Button"

Here's one more way of generating machine key (suggested by Andrei) - for which you have to download the application.
http://www.codeproject.com/KB/aspnet/Machine_Key_Generator.aspx

Hope it helps someone....
13 years ago
Thanks! I am going to check this out -- I'm having issues, and posted about this !
13 years ago
Hi

where in the web config does the machine key need to be as i am not entirely sure where it goes

i am assuming that it needs to replace something in there that would normaly generate it



cheers

phil
13 years ago
pcb666 wrote:
Hi

where in the web config does the machine key need to be as i am not entirely sure where it goes

i am assuming that it needs to replace something in there that would normaly generate it



cheers

phil


Hello phil,

By default the "<machineKey>" tag is not there.


Put your <machineKey> tag inside <system.web> tag like this:

<system.web>
    <machineKey validationKey="111111111" decryptionKey="11111111111" validation="SHA1" decryption="AES" />
----
-----
..........
13 years ago
thanks for the quick reply and the info


I will do it in the morning


thanks again



phil
13 years ago
Does anyone have any feedback on how well this works?

I manually generated a <machinekey> tag via web-tool, and added it to <System.Web>

I still noticed another new one of these errors in the log when I placed it at the end of <System.Web>, so I moved it to immediately after <System.web> (opening tag).

Thoughts?
13 years ago
Have you tried recycling your application pool ??

It is a standard practice when changing these type of ASP.NET settings on a hosting server. Consult your hosting provider documentation to see how it needs to be done.
13 years ago
abcd_12345 wrote:
Have you tried recycling your application pool ??

It is a standard practice when changing these type of ASP.NET settings on a hosting server. Consult your hosting provider documentation to see how it needs to be done.


Thanks abcd, I looked them up and did it. Hopefully now I won't see the error anymore (-8
13 years ago
No such luck, just checked my log this morning, and had another instance of it overnight.

Does the user experience any 'error' when this happens? If so that's really not cool and I need to get this worked out.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.