Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster


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.

You might have come across this error, if you are a .net developer, using ViewState and deployed application in Web Farm.
On deploying asp.net web app into a web farm environment, each web servers machine.config or web.config must specify the same key used for encrypting the view state. Remember the view state is encrypted for security reasons and each machine.config on each web server will have a different key so they must all be the same. 
Best way is to add a machineKey element into each of the web server's web.config and define the same keys and algorithm. The machineKey goes under the System.web node.

<"machineKey validation="SHA1" validationKey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4 E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1B2C3D4E5" 
decryption="Auto" decryptionKey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1" /">

For this you can use a machineKey generator or generate your own if you know how to do it using asp.net code.

Comments

Popular posts from this blog

WCF WSDL location address Issue resolved when hosted over HTTPS with basicHTTPBinding

Yellow Background issue in Word to PDF conversion

Gmail tricks - create unlimited siblings of your Gmail address