asp.net - 登录/注销时未清除 ASP ASPXAUTH 身份验证 cookie

标签 asp.net internet-explorer authentication cookies

我正在使用 ASP 身份验证和集成的 web 服务。

用户在登录页面上使用 Forms 身份验证登录。
要注销,我从 Silverlight 调用身份验证 Web 服务并调用注销。

一切正常,但现在有时 IE 会变得疯狂并且不再注销用户。

我使用了 Fiddler,结果证明身份验证服务返回一个 SetCookie 来清除 ASPXAUTH cookie,但在下一次调用时,IE 仍然设置了 cookie。
当然,因为 cookie 在那里,所以用户经过身份验证并立即重新登录,而不是被定向到登录页面。

我查了一下,没有看到关于这个问题的任何其他描述。
我无法重现它,我的 IE 行为不端的同事让它在一个环境中正常工作,而在另一个环境中却无法正常工作(一个是 DEV 的问题,另一个是 PreProd 服务器的问题)。

知道会发生什么吗?

最佳答案

我遇到了这个问题,为了确保用户被注销,现在我使用以下代码:

        FormsAuthentication.SignOut();

        // Drop all the information held in the session
        Session.Clear();
        Session.Abandon();

        // clear authentication cookie
        HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
        cookie1.Expires = DateTime.Now.AddYears(-1);
        Response.Cookies.Add(cookie1);

        // clear session cookie
        HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
        cookie2.Expires = DateTime.Now.AddYears(-1);
        Response.Cookies.Add(cookie2);

        // Redirect the user to the login page
        Response.Redirect("YourLoginPage.aspx", true);

关于asp.net - 登录/注销时未清除 ASP ASPXAUTH 身份验证 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4387165/

相关文章:

ruby-on-rails - 真实性 token 仅在 React 组件中提交表单后设置,这会在 Rails 中引发错误

java - 如何在 Java 代码中为 ldap 身份验证设置新的安全凭证

javascript - 如何从客户端的 Telerik UI 处理 radgrid 中的 ExpandCollapse?

c# - 使用 SaveChanges 上发生的验证模拟 EF6

javascript - "onchange"事件在 IE 中延迟? (适用于 Firefox)

css - IE7 和 8 CSS 菜单背景下拉悬停问题

asp.net - 为什么这段代码只有在我使用断点时才有效?

html - Visual Basic 登录页面导致错误(错误 BC30506 Handles 子句需要 WithEvents...)

internet-explorer - InternetExplorer.Application 的 Navigate() 中的 header 元素是否可以用于指定代理?

javascript - NGINX 反向代理的 Cookie 路径