Wednesday, June 18, 2008

ERROR: Validation of viewstate MAC failed

Encounter this problem when using AutoPostBack in my web application which uses ViewState.

Error: 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.

Specs:
Microsoft Visual Studio 2005 .Net Framework 2.0
Windows Server 2003

Tried to google for solution and found this workaround which helps to solve my problem.
Link: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic49235.aspx

Solution:
Add the code below into the web.config file.
<system.web>
<pages enableViewStateMac="false" />
<system.web>