0
votes

validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validation Key and validation algorithm. Auto Generate cannot be used in a cluster.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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.

Stack Trace:

[ViewStateException: Invalid viewstate. Client IP: ::1 Port: 49760 Path: /destination.aspx User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 ViewState: ZDL/pAdYwlwxR8MjOlSwmfHswlju0QqWbFMzwqlou/bDqNjXlwYPnwAafMjAAnvPKVDZ6pGzaQd9ROUxtdS3qg0FIf5H6MxrEcFerM99PRw=]

[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.

2

2 Answers

3
votes

Starting with ASP.NET 4.5.2, the runtime enforces EnableViewStateMac=true. If an application sets <%@ Page EnableViewStateMac="false" %> as a directive or as a config setting, the runtime ignores it and pretends that the developer had written "true" instead. Main reason why they do so - it's not safely.

-3
votes

Wrote this code in webconfg.

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.

<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode="Never" enableViewStateMac="false"></pages>

or

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

Reference details