`FormsAuthentication.SignOut ();` does not work for the IIS option `Windows Authentication` enabled

I have the following code in my Visual Studio 2010 C # Web Application. The web application supports Windows Authentication in IIS.

 <script runat="server"> void Signout_Click(object sender, EventArgs e) { FormsAuthentication.SignOut(); Response.Redirect("WebForm1.aspx"); } </script> <body> <form id="form1" runat="server"> <div> <span class="style1"><strong> <asp:HyperLink ID="Link_Home" runat="server" NavigateUrl="~/WebForm1.aspx">Home</asp:HyperLink> &nbsp;| <asp:Button ID="Submit1" OnClick="Signout_Click" Text="Sign Out" runat="server" /> </strong></span><br /> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form> </body> </html> 

However, I noticed that FormsAuthentication.SignOut(); doesn't seem to work. This is because when I click the button. It is supposed to log out and clear the current user, so that when another user comes to this page, he must request a password.

However, when I open another tab and enter the URL of the web application, it does not ask me for a username or password. Only when the web browser closes and reopens with the URL of the web application does it request a username and password.

Appreciate if anyone can help me.

+1
authentication visual-studio-2010
05 Oct '12 at 8:22
source share
1 answer

I used the following code to log out and redirected it to the login page.

 try { document.execCommand("ClearAuthenticationCache"); } catch (e) { } window.location.replace("login.aspx"); 

See below for more details.

  • Logging Out ASP.NET Windows Authentication

  • How to redirect to another webpage in javascript / jQuery?

+3
09 Oct '12 at 5:14
source share



All Articles