ASP.NET Windows 身份验证注销 [英] ASP.NET Windows Authentication logout

查看:43
本文介绍了ASP.NET Windows 身份验证注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在像 web.config 这样的 ASP.NET 中使用 Windows 身份验证时,您如何注销?

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("/");
}

背景信息:

我必须使用 Windows 身份验证,因为我需要使用 Active Directory 模拟身份才能访问本地文件.而且我无法使用 Forms 身份验证进行模拟,因为 HttpContext.Current.User.Identity 不会是 WindowsIdentity.模拟使用表单身份验证

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

推荐答案

使用Windows"身份验证时,服务器端注销按钮将不起作用.如果您想要退出按钮或关闭用户的浏览器,则必须使用表单"身份验证.

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.

这篇关于ASP.NET Windows 身份验证注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆