1

Please don't mark this post as duplicated.. Please help me to fix my issue since I am very new to asp.net I have some difficulties with understanding.

I am working on VS 2010 and try to familiarize with asp.net web site. I have two web pages called Default.aspx and Result.aspx.

Default.aspx

<form id="Form1" runat="server" action="Result.aspx">  
    //Some Controllers (Dynamically added textboxes and submit button)
</form>  

Once I fill the form and when it is submit following error comes.

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.

I tried to add EnableViewStateMac="false" but have no luck.

Please advice me to fix this and appreciate if you could explain me why this comes.

Community
  • 1
  • 1
New Developer
  • 3,245
  • 10
  • 41
  • 78

1 Answers1

2

ASP.NET has a very different model to other languages in web development, designed to emulate the Windows Forms development paradigm. Whereas in other languages it is common to post to another URL, operations in ASP.NET are usually accomplished by posting back to events on the same page. The issue you are experiencing is related to the fact you are posting ViewState to another page, see http://blogs.msdn.com/b/tess/archive/2009/04/14/validation-of-viewstate-mac-failed-after-installing-net-3-5-sp1.aspx.

As an aside, you shouldn't set EnableViewStateMac=false" on a production server, it is a mechanism to prevent tampering of the data held in viewstate by the user, switching it off removes this protection - and only deals with a symptom of the problem, not the cause.

I don't think this is the issue in this case, but with this error it's always worth checking that you're not setting the ViewStateUserKey to the Session ID before you have stored data in the session (ASP.NET will not track Session IDs where the session does not contain data).

pwdst
  • 13,909
  • 3
  • 34
  • 50