blog posts

How to fix ASP.NET error – Validation of ViewState MAC Failed

When hosting your ASP.NET applications on Windows Web Hosting server, your website may face a common error usually when you Submit a Form on your website like a Contact Form or a Registration Form. The error will read like below. “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”

To get rid of this error in your application, please add the below code to your web.config file to solve the validation of viewstate mac issue. <system.web> <pages enableViewStateMac=”False” /> </system.web> Please note that most probably there must be already a and element in your web.config file so just add the attribute enableViewStateMac to start of element. If issue still persists, then please also add below to your web.config file.

<system.web> <machineKey validationKey=”B74B4D90C95A2D55EB91C92D679EDF493706FBA967A47CFE424 216381C08F5E51F71F5972FA8AD3DEB052CF7AE81526DF90DE9F9FB587BA7A18 9380CC5A69D1A” decryptionKey=”5842BCF01CD711850026B5105290A350A423864F037523892CAF 4B25FD44B27C” validation=”SHA1″ decryption=”AES” /> </system.web>

We hope this helps.