4

net 4.0 frame work, I had made many website in this frame work but never get such error

 "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."

I think so this error is caused because of use of cookies as only in this website i had made use of cookies.

Another one thing i used to get this error very rarely almost 2twice a week

I had read many solutions for this but very rarer for 4.0

solution readed such as putting

<machineKey validationKey="6628ECBFB40F6F852AB543C23C0B83C1679C5AAE35AD72FACF5B9F4FDB70AA1F648A1D5877CE1F9D69F08BAD919BFBAC0976D9119B8F32CFB80814E4E943F8EE" decryptionKey="42F45B378301126EB4CCBA16995304263754EF116E08A81003A936CC04B7537F" validation="SHA1" decryption="AES" /> 

in web config OR Adding

<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />

in webconfig

But where should i add in my above web config

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
<add name="Conn" connectionString="Data Source=abc; Initial Catalog=alfadesi_trikon;User ID=abc;Password=abc" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<globalization culture="en-AU" uiCulture="en-AU" />
    <compilation debug="true" targetFramework="4.0"/>
<authentication mode="Windows"/>
<customErrors mode="Off"></customErrors>    
</system.web>
</configuration>
Mitesh Jain
  • 555
  • 4
  • 13
  • 40

1 Answers1

4

you can add your machine key in system.web element. for e.g.

<system.web>
<machineKey validationKey="1234567890123456789012345678901234567890AAAAAAAAAA"
 decryptionKey="123456789012345678901234567890123456789012345678"
 validation="SHA1" decryption="Auto" />
</system.web>

If you don't want to put a machinekey in the web.config for each application, you need to put it in machine level web.config for each .Net Framework version.

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
vendettamit
  • 14,315
  • 2
  • 32
  • 54