如何在ASP.NET中使用Windows身份验证时注销,如此web.config?
<authentication mode="Windows" />
Run Code Online (Sandbox Code Playgroud)
我已经尝试过以下尝试失败了.它重定向,但不会注销用户.
void logoutButton_Click(object sender, EventArgs e) {
HttpContext.Current.Session.Clear();
HttpContext.Current.Session.Abandon();
ViewState.Clear();
FormsAuthentication.SignOut();
Response.Redirect("/");
}
Run Code Online (Sandbox Code Playgroud)
背景资料:
我必须使用Windows身份验证,因为我需要使用Active Directory模拟身份以获取对本地文件的访问权限.而且我无法模仿使用Forms身份验证,因为它HttpContext.Current.User.Identity不会是一个WindowsIdentity.
使用表单身份验证进行模拟