Vit*_*lii 12 c# authentication session asp.net-mvc-4
对于我的网站,我在web.config文件中配置了1周的登录会话超时
<system.web>
<httpRuntime />
<!-- Session keeps for 7 days -->
<sessionState timeout="10080"></sessionState>
<authentication mode="Forms">
<forms loginUrl="~/" timeout="10080" slidingExpiration="true"/>
</authentication>
<!-- Configuration end -->
</system.web>
Run Code Online (Sandbox Code Playgroud)
这是登录的代码
[AllowAnonymous]
[HttpPost]
public ActionResult Login(string Login, string Password)
{
// empty passwords are not allowed
if (Password == "")
return Redirect(Request.UrlReferrer.ToString());
bool LoginResult = WebSecurity.Login(Login, Password, true);
return Redirect(Request.UrlReferrer.ToString());
}
Run Code Online (Sandbox Code Playgroud)
我登录,关闭浏览器并再次打开它进入我的网站 - >用户已登录.我关闭浏览器,等待一段时间(约30分钟)转到我的网站 - >用户已注销.为什么?会话应存储7天,但我们甚至没有30分钟.Whan可能是问题的根源?
编辑1 主要想法是我想在几天内回到网站,并仍然使用登录用户打开它