此应用程序运行的环境中,一些用户仍在使用 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("/");
}
该应用正在使用保存到数据库中的 session ,因为它在两个不同的 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>
最佳答案
如果您使用 FormAuthentication 像这样登录 -
FormsAuthentication.SetAuthCookie("username", false);
那么注销应该是
FormsAuthentication.SignOut();
如果仍有问题,您可以强制 cookie 过期,如 this .
关于asp.net-mvc - ASP.Net MVC 应用程序注销未完全注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18280972/