Asp.net mvc 从windows身份验证应用程序注销

Asp.net mvc 从windows身份验证应用程序注销,asp.net-mvc,active-directory,windows-authentication,Asp.net Mvc,Active Directory,Windows Authentication,我想开发一个Web应用程序,用户可以使用active directory中的数据自动登录或注销,以获得一个表单,用户可以在该表单中输入其他用户数据以作为其他用户登录。 我在web.config中设置了 <authentication mode="Windows"/> <authorization> <deny users="?" /> </authorization> 但我总是被登录。如何注销并打开一个简单的表单来输入另一个用户的用户数据

我想开发一个Web应用程序,用户可以使用active directory中的数据自动登录或注销,以获得一个表单,用户可以在该表单中输入其他用户数据以作为其他用户登录。 我在web.config中设置了

<authentication mode="Windows"/>
<authorization>
  <deny users="?" />
</authorization>

但我总是被登录。如何注销并打开一个简单的表单来输入另一个用户的用户数据?

您不能使用Windows身份验证注销,这就是这种身份验证的全部思想:您登录到Windows,从现在开始只需一次登录。您将需要在其他用户下打开浏览器


如果您想启用此功能,您可以使用带有模拟的针对广告的表单身份验证。

我可以使此功能正常工作,但它仅适用于IE,而不适用于FireFox或我所知道的其他浏览器

<input id="LogoutButton" type="button" value="Log Out" />

<script>
    $(document).ready(function () {

        $("#LogoutButton").bind("click", function () {


            try {
                if (window.XMLHttpRequest) {
                    alert("You have been logged off from the website");
                    document.execCommand("ClearAuthenticationCache", "false");
                    window.location = "http://www.stackoverflow.com"
                    if (top.location != location) {
                        top.location.href = ".";


                    }
                    window.location = "http://www.stackoverflow.com"
                }

            }
            catch (e) {
                alert("This feature requires IE 6.0 SP1 or above. " + "Please close all browser windows in order to complete the logout process.");
            }
        });

    });
</script> 

$(文档).ready(函数(){
$(“#注销按钮”).bind(“单击”,函数(){
试一试{
if(window.XMLHttpRequest){
警报(“您已从网站注销”);
document.execCommand(“ClearAuthenticationCache”、“false”);
window.location=”http://www.stackoverflow.com"
if(top.location!=位置){
top.location.href=“.”;
}
window.location=”http://www.stackoverflow.com"
}
}
捕获(e){
警报(“此功能需要IE 6.0 SP1或更高版本。”+“请关闭所有浏览器窗口以完成注销过程。”);
}
});
});

如果您是从不属于域的设备(如我们的Android平板电脑)访问站点,则广告登录的工作原理与表单登录类似,在表单登录中会提示输入用户名和密码。在这种情况下,让用户注销是有意义的。这个答案在IE11中不起作用。我认为这是一个非常古老的答案,可能在旧的ie版本中工作。