title: Validation of viewstate MAC failed.Application hosted by a Web Farm, ensure <machineKey> configuration
body: <p>net 4.0 frame work,
  I had made many website in this frame work but never get such error </p>
  
  <pre><code> "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that &lt;machineKey&gt; configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
  </code></pre>
  
  <p>I think so this error is caused because of use of cookies as only in this website i had made use of cookies.</p>
  
  <p>Another one thing i used to get this error very rarely almost 2twice a week</p>
  
  <p>I had read many solutions for this but very rarer for 4.0 </p>
  
  <p>solution readed such as putting</p>
  
  <pre><code>&lt;machineKey validationKey="6628ECBFB40F6F852AB543C23C0B83C1679C5AAE35AD72FACF5B9F4FDB70AA1F648A1D5877CE1F9D69F08BAD919BFBAC0976D9119B8F32CFB80814E4E943F8EE" decryptionKey="42F45B378301126EB4CCBA16995304263754EF116E08A81003A936CC04B7537F" validation="SHA1" decryption="AES" /&gt; 
  </code></pre>
  
  <p>in web config
  OR Adding</p>
  
  <pre><code>&lt;pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" /&gt;
  </code></pre>
  
  <p>in webconfig</p>
  
  <p>But where should i add in my above web config</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
  &lt;add name="Conn" connectionString="Data Source=abc; Initial Catalog=alfadesi_trikon;User ID=abc;Password=abc" providerName="System.Data.SqlClient"/&gt;
  &lt;/connectionStrings&gt;
  &lt;system.web&gt;
  &lt;globalization culture="en-AU" uiCulture="en-AU" /&gt;
      &lt;compilation debug="true" targetFramework="4.0"/&gt;
  &lt;authentication mode="Windows"/&gt;
  &lt;customErrors mode="Off"&gt;&lt;/customErrors&gt;    
  &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>