title: IIS6 & IIS7 forms auth compatibility
body: <p><strong>Background:</strong></p>
  
  <p>I have two web applications, set up on different web servers, which are currently both IIS6. Application 1 (A1 - a1.domain.com) uses the forms auth cookie set by application 2 (A2 - a2.domain.com).</p>
  
  <p>In A1 web.config I have:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
  &lt;forms name=".ASPXAUTH" domain="domain.com"  protection="All" path="/" loginUrl="http://a2.domain.com/login.aspx" timeout="60" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>In A2 web.config I have:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
  &lt;forms name=".ASPXAUTH" domain="domain.com"  protection="All" path="/" loginUrl="login.aspx" timeout="60" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>These two applications also share machineKey values in web.config</p>
  
  <p><em><strong>This works perfectly without any problems.</em></strong></p>
  
  <p><strong>Problem:</strong></p>
  
  <p>I am upgrading A1 to use .NET 4.0 and run in IIS7, and now the shared forms authentication does not work. I am still redirected to the correct login page on A2 and I can see that it sets the auth cookie, but when I go back to A1 the authentication fails with the following error (from Event Viewer):</p>
  
  <p><em>Forms authentication failed for the request. Reason: The ticket supplied was invalid.</em></p>
  
  <p>I have tried:</p>
  
  <ul>
  <li><p>Setting up upgraded version of A1 in IIS6 (this worked - so no compatibility issues between forms auth in different .NET versions in IIS6)</p></li>
  <li><p>Setting up upgraded A1 in IIS7 using a local login page i.e. copied login page from A2 into A1 and set A1 loginUrl="login.aspx" (also works)</p></li>
  </ul>
  
  <p>This has left me guessing that there is some compatibility issue caused by the auth cookie being created under an IIS6 site being used to authenticate users under an IIS7 site.</p>
  
  <p>Does anyone know how to solve this?</p>