1

I keep getting this viewstate validation error:

System.Web.HttpException (0x80004005): 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. ---> System.Web.UI.ViewStateException: Invalid viewstate...

I have ARR load balancing the site and I think when it switches a user from one server to another (even though I have affinity selected) it throws this. HOWEVER - I have the machine key configured and I have the same encryption method, decryption method, validation key and decryption key configured on both of the two servers in the farm. Am I missing something?

Stewart Anderson
  • 333
  • 2
  • 14
  • It emails me unhandled exceptions (from Global.asax) which is how I receive these errors. It's only occasional because I have affinity setup in the load balancing so users only very occasionally get sent to a different server in the farm. – Stewart Anderson Jul 06 '12 at 22:07
  • If you get this message occasional, then check again this answer, it can help you find the reason http://stackoverflow.com/questions/1821243/cryptographicexception-padding-is-invalid-and-cannot-be-removed-and-validation/2551810#2551810 – Aristos Jul 06 '12 at 22:10
  • I don't think they were talking about a load balanced environment though. Also I can consistently & predictably cause the exception by removing the affinity cookie to land on a different server and then resending the postback. So I know the problem is validating the viewstate key between the two servers. – Stewart Anderson Jul 06 '12 at 22:25
  • (I meant validating the viewstate mac (not key)) – Stewart Anderson Jul 06 '12 at 22:35

1 Answers1

0

One of our servers was behind on Windows updates and after running those updates the problem appears to be gone. I've re-run the exact tests that consistently invoked this exception before and it's not having any issues.

Stewart Anderson
  • 333
  • 2
  • 14