ASP.NET Windows Authentication logout
asp.net, logout, windows-authentication
Solution
No server-side logout button will work when using "Windows" authentication. You must use "Forms" authentication if you want a logout button, or close the user's browser.
Problem
How do you logout when using Windows authentication in ASP.NET like this web.config? ``` <authentication mode="Windows" /> ``` I've already tried the following unsuccessfully. It redirects, but does not log out the user. ``` void logoutButton_Click(object sender, EventArgs e) { HttpContext.Current.Session.Clear(); HttpContext.Current.Session.Abandon(); ViewState.Clear(); FormsAuthentication.SignOut(); Response.Redirect("/"); } ``` Background Info: 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 `HttpContext.Current.User.Identity` won't be a `WindowsIdentity`. Impersonate using Forms Authentication