genericuser
genericuser

Reputation: 1450

aspx page gives viewstate error

I have a simple aspx page with one grid view. When deployed on server, and accessed through that machine, it works fine. However, when connected through load balancer, we get this error ( when click on any button). The page however refreshes when pressed F5.

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.

Any idea what is happening here???

Upvotes: 1

Views: 284

Answers (2)

genericuser
genericuser

Reputation: 1450

Added enableViewStateMAC = false on the page directive

Upvotes: 0

Stilgar
Stilgar

Reputation: 23561

You should set the machineKey on your web.config to be the same for all load balanced servers. The machine key is used to encrypt, validate, hash, etc. all ASP.NET internal stuff. When the ViewState is created on one machine it is created with the machine key for that machine the other machine cannot validate it because its key is different. Despite the fact that it is called machine key it can be set per application.

There are multiple generators for machine keys (it is not hard to write one). Here is the first Google hit: http://aspnetresources.com/tools/machineKey

Upvotes: 2

Related Questions