title: ASP.NET Windows Authentication logout
body: <p>How do you logout when using Windows authentication in ASP.NET like this web.config?</p>
  
  <pre><code>&lt;authentication mode="Windows" /&gt;
  </code></pre>
  
  <p>I've already tried the following unsuccessfully.  It redirects, but does not log out the user.</p>
  
  <pre><code>void logoutButton_Click(object sender, EventArgs e) {
      HttpContext.Current.Session.Clear();
      HttpContext.Current.Session.Abandon();
      ViewState.Clear();
      FormsAuthentication.SignOut();
      Response.Redirect("/");
  }
  </code></pre>
  
  <p>Background Info:</p>
  
  <p>I have to use Windows authentication because I need to impersonate the identity using Active Directory to gain access to local files.  And I cannot impersonate using Forms authentication because the <code>HttpContext.Current.User.Identity</code> won't be a <code>WindowsIdentity</code>.
  <a href="https://stackoverflow.com/questions/1066275/impersonate-using-forms-authentication">Impersonate using Forms Authentication</a></p>