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 W开发者_高级运维eb 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???
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
Added enableViewStateMAC = false on the page directive
精彩评论