2

I have an mvc2 project built for .NET 3.5. I have a library that I wrote in 4.0 that I need for the 3.5 project, so I changed the target framework and now the anywhere the anti-forgery token it throws:

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

I found this question but no luck with any of the suggestions. I created a static machine key in my config but it doesn't help. Anybody have any idea what could be the problem. I don't understand why it worked fine before.

Community
  • 1
  • 1
Nick
  • 1,903
  • 2
  • 21
  • 40

1 Answers1

4

You have to close all browser windows to continue.

The AntiForgeryToken cookie is a session-cookie, and is encrypted / decrypted using the machine key. If the machine key changes (or is set to auto-generate), then rendering the AntiForgeryToken will fail.

Restarting your browser windows will clear the cookie, and MVC will create a new, valid cookie next time.

Scott Rippey
  • 15,614
  • 5
  • 70
  • 85
  • that's what I thought. I have restarted the browser, cleared all cookies, even restarted my computer but still get the error. It's really pretty frustrating – Nick Jan 18 '12 at 21:42
  • 2
    Nevermind, I just cleared the cookies and closed the browser again and it's working. Don't know what I did the first time, I think it's time for me to go home, thanks! – Nick Jan 18 '12 at 21:48