Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 过期的会话cookie阻止成功登录_Asp.net_Forms Authentication_Session Timeout - Fatal编程技术网

Asp.net 过期的会话cookie阻止成功登录

Asp.net 过期的会话cookie阻止成功登录,asp.net,forms-authentication,session-timeout,Asp.net,Forms Authentication,Session Timeout,对于使用表单身份验证的ASP.NET web应用程序,我在Global.asax中添加了以下代码,以在用户会话到期时注销用户: void Session_Start(object s, EventArgs e) { if (Request.IsAuthenticated) { FormsAuthentication.SignOut(); /* cache clean up code */ FormsAuthentication.Re

对于使用表单身份验证的ASP.NET web应用程序,我在
Global.asax
中添加了以下代码,以在用户会话到期时注销用户:

void Session_Start(object s, EventArgs e)
{
    if (Request.IsAuthenticated)
    {
        FormsAuthentication.SignOut();
        /* cache clean up code */
        FormsAuthentication.RedirectToLoginPage();
    }
}

这是为了防止由于在预先存在的代码中未经检查地使用
会话
变量而导致的问题。然而,我注意到,每当会话到期而用户未登录时,代码就会阻止成功登录,从而不断地将用户重定向到登录页面。问题似乎在于会话cookie保持设置,不允许会话续订,因为删除它会重新启用正常登录。编辑会话cookie的值也会导致登录循环。

我找到了解决上述问题的方法。附加:

else
    Session.Add("dummy", 0);
解决了这个问题,尽管它看起来有点不正统。空会话似乎无法续订会话cookie中的会话id