| Home » Categories » Multiple Categories |
How to Solve an Error Message "Validation of viewstate MAC failed" |
|
Article Number: 149 | Rating: 3.7/5 from 3 votes | Last Updated: Tue, Sep 23, 2025 at 11:18 PM
|
Usually we won’t got "Validation of viewstate MAC failed” error in our site all the time. Normally the site works fine and doesn't throw any errors if you load the site and use it at a regular pace. The error only occurs when you load the page, leave it for a while, and then continue working on the page without reloading or refreshing it. I discovered this error because I opened the site, began using it, left for lunch, came back an hour later, and when I resumed using it and did anything that caused postback, it immediately threw the above error. Unfortunately in order to re-create the error, I have to wait a while, which is very inconvenient for testing/troubleshooting. After a few hours of reasearch I found the solutions:
Error message:
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.
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.
Solution:
Yet another very teasing issue ASP .Net developers face. Solution is pretty much simple.
Add following link in your web.config file.
<pages enableEventValidation="false" viewStateEncryptionMode="Never" />
Above line should be included within section.
OR
if you don't want this solution to implemented on project level then you can add these attribute to the page(Top most line of HTML view) directive of the page which is creating issue.
That means you have to add enableEventValidation="false" viewStateEncryptionMode="Never" in page directive.
|
Attachments
There are no attachments for this article.
|
I cannot see my website. What should I do?
Viewed 4243 times since Thu, May 3, 2012
HTTP Error 502.5 - Process Failure error message when publishing an ASP.NET Core Website
Viewed 11311 times since Mon, Mar 27, 2017
My site is showing 500 Internal Server error message. What is wrong here?
Viewed 4246 times since Thu, May 3, 2012
Do you support ASP.NET MVC 6?
Viewed 5308 times since Wed, Feb 17, 2016
I receive this error message: "Directory Listing Denied. This Virtual Directory does not allow contents to be listed."
Viewed 11162 times since Mon, Apr 30, 2012
I cannot find a way to enable ASP.NET 4.5 on my Control Panel
Viewed 11453 times since Tue, Sep 11, 2012
Why do I suddenly receive the error message: "Compiler Error Message: The compiler failed with error code XXXXXXXXX"?
Viewed 18195 times since Wed, Feb 17, 2016
Sample Code to Send email using ASP.NET1.1
Viewed 5883 times since Tue, May 1, 2012
I get an error Server.CreateObject Failed when I try to use CDONTs. What can I do?
Viewed 3349 times since Tue, May 1, 2012
How to solve ReportViewer error message: "An error has occurred during report processing. Input string was not in a correct format"
Viewed 8672 times since Tue, Jun 18, 2013
|
