title: IIS 7.5 Windows + Anonymous Authentication works intermittently
body: <p>I have an MVC 3 site in which some controllers/action require Windows authentication, other do not, i.e. are anonymous.</p>
  
  <p>The site runs fine for a while, I can access both the anonymous actions and authenticated ones (without prompting, credentials are passed automatically in Chrome/IE/FireFox) but then the authentication just stops working, I start getting prompted for credentials that are never accepted.</p>
  
  <p>I have to either restart the whole server, or change the site physical path to another app, make an authenticated request, which works, when back to the original site.  The situation is then rinse and repeat, but I can find no pattern to it.  If I do nothing, the authentication stays broken.</p>
  
  <p>I have IIS 7.5 configured as follows:</p>
  
  <p>App Pool</p>
  
  <ul>
  <li>.NET Framework Version - v4.0</li>
  <li>Managed Pipeline Mode - Integrated</li>
  <li>Application Pool Identity - ApplicationPoolIdentity</li>
  </ul>
  
  <p>Site</p>
  
  <ul>
  <li>Anonymous Authentication - Enabled</li>
  <li>Anonymous user identity - IUSR [I believe this is the default]</li>
  <li>ASP.NET Impersonation - Disabled</li>
  <li>Forms Authentication - Disabled</li>
  <li>Windows Authentication - Enabled</li>
  <li>Windows Authentication Extended Protection - Off</li>
  <li>Windows Authentication Enable Kernel-mode authentication - On</li>
  <li>Windows Authentication Providers - Negotiate, NTLM</li>
  </ul>
  
  <p>Controllers</p>
  
  <pre><code>// Anonymous Controller
      public class HomeController : Controller
      {
         public ActionResult Index()
         {
            return this.View();
         }
      }
  
  // Authenticated Controller
      [Authorize]
      public class AnotherController : Controller
      {
         public ActionResult Index()
         {
            var viewModel = // create view model;
            return this.View(viewModel);
         }
      }
  </code></pre>
  
  <p>At all times, authentication working or not a GET to /home/index returns 200. Exactly as expected.
  When authentication is working a GET request to /another/index looks like this:</p>
  
  <pre><code>&gt; GET /another/index
    Response: 401
    Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate
  
  
  &gt; GET /another/index
    Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
    Response: 401
    Response Header: WWW-Authenticate: Negotiate TlRMTVNTUAACAAAACAAEADgAAAAVgoni2YSlwIHmCL4AAAAAAAAAAIgAiAA8AAAABgGxHQAAAA9GAFIAAgAEAEYAUgABABQARgBSAEkATgBUAFIAQQBOAEUAVAAEABQARgBSAC5ATgBEAFMALgBjAG8AbQADACoARgBSAKkATgBUAFIAQQBUAEUAVAAuAGCAcgAuAG4AZACzAC4AYvBvAG0ABQAOAE4ARABTAC6AYwBvAG0ABwAIAOST3lPK980BAAAAAA==
  
   &gt; GET /another/index
     Request Headers: Authorization: Negotiate TlRMTVNTUAACAAAACAAEADgAAAAVgoni2YSlwIHmCL4AAAAAAAAAAIgAiAA8AAAABgGxHQAAAA9GAFIAAgAEAEYAUgABABQARgBSAEkATgBUAFIAQQBOAEUAVAAEABQARgBSAC5ATgBEAFMALgBjAG8AbQADACoARgBSAKkATgBUAFIAQQBUAEUAVAAuAGCAcgAuAG4AZACzAC4AYvBvAG0ABQAOAE4ARABTAC6AYwBvAG0ABwAIAOST3lPK980BAAAAAA==
     Response: 200
  </code></pre>
  
  <p>When authentication breaks a GET request to /another/index looks like this:</p>
  
  <pre><code>&gt; GET /another/index
    Response: 401
    Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate
  
  
  &gt; GET /another/index
    Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
    Response: 401
    Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate
  </code></pre>
  
  <p>At this point I am prompted for credentials, which I enter, the same request, response is resent:</p>
  
  <pre><code>&gt; GET /another/index
        Request Header: Authorization: Negotiate TlRMIVNDUAACAAAAl4II4gAAAAAAAAAAAAAAAAAAAAAGAbEdAAAADw==
        Response: 401
        Response Headers: WWW-Authenticate: NTLM, WWW-Authenticate:Negotiate
  </code></pre>
  
  <p>Does anyone know if I have something misconfigured (I'm fairly sure I don't or I wouldn't expect it to work at all), why the authentication breaks or how I can stop it?</p>
  
  <p>Many thanks all.</p>