此应用程序正在一些用户仍在使用IE7的环境中运行,如果这有任何区别的话。我们所看到的有时是在有人退出并且其他人登录之后,他们仍然会从之前的人那里得到残余物,这可能表明人员的个人资料。任何建议都将不胜感激。
我在我的asp.net mvc应用程序中使用以下作为注销方法
public ActionResult LogOff()
{
System.Web.HttpContext.Current.Response.Cookies.Clear();
FormsService.SignOut();
Session["User"] = null;
Session.Clear();
Session.Abandon();
Session.RemoveAll();
return Redirect("/");
}
该应用正在使用保存在数据库中的会话,因为它在两个不同的Web服务器上运行。
以下是web.config中的一些设置
<sessionState sqlConnectionString="LiveDB" />
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LiveDB" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="50" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="LiveDB" applicationName="/" />
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="LiveDB" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
答案 0 :(得分:4)
如果您使用FormAuthentication进行此类登录 -
FormsAuthentication.SetAuthCookie("username", false);
然后Logout应该是
FormsAuthentication.SignOut();
如果您仍有问题,可以强制Cookie过期,如this。
答案 1 :(得分:0)
Membership
和Session
提供商的工作非常有效。两名成员可以使用一个会话。这不是一个规则,但它可以。
我不确定,但我对你的问题有一个建议。 Session
拥有财产IsNewSession
。微软说,它“获取一个值,表明会话是否是使用当前请求创建的。”
因此,您可以尝试检查登录用户的Session
是否为新用户,因为他可能与旧用户共享会话,而且可能是,这是一个原因,为什么会看到其他人的个人资料。< / p>