title: ASP.NET app having viewstate corrupted every few minutes
body: <p>I'm having a problem with a web app I'm managing. Users starting receiving the following error occasionally:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>The problem is that it's not a cluster - it's a single Windows 2003 server. After digging around, it appears that adding a <strong>machineKey</strong> section and some extra attributes to the <strong>Pages</strong> directive in my web.config resolves this error:</p>
  
  <pre><code>&lt;machineKey validationKey='MACHINE KEY SNIPPED'
          decryptionKey='DECRYPTION KEY SNIPPED'
          validation='SHA1'/&gt;
  
  &lt;pages validateRequest="true" enableEventValidation="false"&gt;
  </code></pre>
  
  <p>After changing these two things in my web.config, the error goes away, but <strong>now I have a new problem - Instead of an error that my viewstate is invalid, the app just "Forgets" who my user is, and sends them back to the login page</strong>. Now, the users are browsing through the application, and then they're unexpectedly sent to the login page, even after they've already been logged in for a few minutes. While I can't force this to happen, it usually happens within visiting 10-12 different pages, so pretty frequently.</p>
  
  <p>I'd love a resolution to this - does anybody know what else might be causing the viewstate error on a single server, or what I can do to ensure that it's validated properly?</p>