Iis – Is this a valid way to avoid Invalid View state in ASP.NET Web farms

asp.netiisnet

We have problem with users getting invalid view state exceptions in our web farm setup (ASP.NE.

In the machine.config we have this setting:

<section name="machineKey" type="System.Web.Configuration.MachineKeySection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b04f6f7f22b50a3c" allowDefinition="MachineToApplication"/>

I've read that it should look like this:

<machineKey validationKey='A130E240DF1C49E2764EF8A86CEDCBB11274E5298A130CA08B90EED016C0
14CEAE1D86344C29E67E99DF83347E43820050A2B9C9FC89E0574BF3394B6D0401A9'
decryptionKey='2CC37FFA8D14925B9CBCC0E3B1506F35066FEF33FEB4ADC8' validation='SHA1'/>

Does the former do the same thing? Or can this be the answer to our View State problems?

The servers are running .NET 3.5 and IIS 7.0 (or maybe IIS 6.0).

Best Answer

Yes, this could be your problem. If you have a server farm (i.e. more than one web server) you need to ensure that the machinekey settings are the same on all servers.

If you do not do this then you can end up with invalid view state errors if a request is generated on Server A and then posted back to Server B.