1
votes

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?

1
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
If you get this message occasional, then check again this answer, it can help you find the reason stackoverflow.com/questions/1821243/…Aristos
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
(I meant validating the viewstate mac (not key))Stewart Anderson

1 Answers

0
votes

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.