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.

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.

This error is usually caused by the asp.net worker process or the server recycling. By default, ASP.NET encrypts the viewstate using an Autogenerated Key when the process spins up. The problem comes when a client (browser) sends the request with a viewstate encrypted with the key generated by another worker process. Since the key is different, ASP.NET will not be able to decrypt the viewstate and it will throw the above error.

There are several ways to get around this problem:

1) Host your site on a server where the application pools never recycle! Obviously, this is impossible.

2) Disable ViewstateMac by putting this “enableViewStateMac="false"” in your web.config. This approach is not 100% secure.

3) Configure ASP.NET to not use Auto-Generated Key but rather a predefined key. This is the preferred method.

To do this, follow these steps:

a) Either build your own Key Generator (http://support.microsoft.com/kb/313091/EN-US/)or use this tool (http://www.aspnetresources.com/tools/keycreator.aspx). I highly recommend you use the online tool. So assuming you will use the online tool:

b) In the online tool, simply click on “Generate”.

c) Copy the content in the textbox into your site’s web.config file. The machineKey node should be within <system.web>

eg.

<?xml version="1.0"?>

<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<machineKey
validationKey="2EEA416CEFC6D6BE856ED57B97FB9CA7DFACE17C073125949A1D682C80A44BB2A
D887DDDC13DBFB0954F1000FEE5757E99693F222F8E28CAA2E6DAB8C4F99E0C"
decryptionKey="877478B2F33A74226ABEF55FDCC1A76E43F1BBEA6241A592"
validation="SHA1" />
<compilation debug="false"/>
<authentication mode="Windows"/>
<pages enableViewStateMac="true"/>
</system.web>
</configuration>

For more information on viewstate troubleshooting, see http://support.microsoft.com/default.aspx?scid=kb;EN-US;829743

  • 69 Utenti hanno trovato utile questa risposta
Hai trovato utile questa risposta?

Articoli Correlati

Disable Directory Browsing or Listing in PLESK

Directory listing will be disabled. Step 1:Login to Plesk Step 2:Goto Domains -> Domain Name...

Enable Parent Paths in Plesk - Windows Server

Many scripts use a function called parent paths. If you are running one of these scripts and find...

Plesk Windows Scheduler to call an ASP or ASP.NET

1. Click on 'Scheduled Tasks' in Plesk 2. 'Add New Task' 3. Enter a Description and Email if...

How to create Addon domain in plesk?

If you have a hosting plan in which you can host more than single domain but you don't know the...

Error "Your connection is not private" in windows.

If you are getting error "Your connection is not private" while opening in plesk then you can...