ASP.NET Cafe
Tips and Tricks

Solution for "Validation of viewstate MAC failed / The state information is invalid for this page and might be corrupted"

Monday, 10 December 2007 07:02 by Dmitriy

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.

At least one time in you life you see this message. And this can be a real problem... It's infrequent and hard to reproduce this error.
They are saying something about cluster? I'm on shared hosting... So, why this problem occurs?

It's hard to find why this error occurs. But let me explain why. IIS can shutdown your application if there are no request during some time... And this is because someone just fills big form! (and no other visitors this time). And when someone submits a long form, he receives this, message. I don't know, maybe this was a problem only for me. But solution is quite simple! Always use generated <machineKey>. There are another question... How to generate it? I've found a tool long time ago...

So, use MachineKey generator http://www.aspnetcafe.com/tools/machineKey.aspx

Maybe this stuff can save you several hours... usually, for beginners in ASP.

Currently rated 3.8 by 4 people

  • Currently 3.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , ,
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (6) | Comment RSSRSS comment feed

Related posts

Comments

January 3. 2008 15:24

MattNecromancer

Thanx so much for your help,this was so goo d for me.

MattNecromancer

February 5. 2008 02:55

Yogs

With Which Tag we have set this generated machine in web.config

Yogs

February 5. 2008 06:18

D

Yogs, you should add generated
"<machineKey validationKey="xxx" decryptionKey="xxx"
validation="SHA1" decryption="AES"/>"
in <configuration> section of web.config

D

March 5. 2008 11:56

R

Hard to tell if it worked since it's so inconsistent, but thanks.

R

April 30. 2008 11:08

Android

I just used this and it solves my problem - thanks Dmitriy - but one detail is wrong: You have to add the <machineKey> to the <system.web> section, NOT <configuration>.

Android

June 9. 2008 16:26

eCommerce Consulting

Thanks Dmitriy - this fix worked like a charm and yes, it needs to be added to system.web as Android pointed out (and the machine key generator page notes)

eCommerce Consulting

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

August 20. 2008 11:11