ASP.NET Windows Authentication注销

15 浏览
0 Comments

ASP.NET Windows Authentication注销

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


我已经尝试了以下方法,但没有成功注销用户,它只是重定向。

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

使用Forms身份验证进行模拟

0