Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.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 是不是;HttpContext.Current.User.Identity.Name“;如果会话超时,则返回null?_Asp.net_Asp.net Mvc 4 - Fatal编程技术网

Asp.net 是不是;HttpContext.Current.User.Identity.Name“;如果会话超时,则返回null?

Asp.net 是不是;HttpContext.Current.User.Identity.Name“;如果会话超时,则返回null?,asp.net,asp.net-mvc-4,Asp.net,Asp.net Mvc 4,我正在开发Formsauthentication登录功能 我的会话配置是1分钟 <sessionState cookieless="false" timeout="1"/> 因此,当我访问“HttpContext.Current.User.Identity.Name”时,我会得到用户ID 如果会话超时(1分钟后),我认为“HttpContext.Current.User.Identity.Name”也将过期。但是值仍然存在,我仍然在1分钟后获得用户ID。这个值存储在哪里 该值是否从

我正在开发Formsauthentication登录功能

我的会话配置是1分钟

<sessionState cookieless="false" timeout="1"/>
因此,当我访问“HttpContext.Current.User.Identity.Name”时,我会得到用户ID

如果会话超时(1分钟后),我认为“HttpContext.Current.User.Identity.Name”也将过期。但是值仍然存在,我仍然在1分钟后获得用户ID。这个值存储在哪里

该值是否从cookie中读取并通过请求发送

如果登录cookie过期(我在这里避免使用该术语),则
HttpContext.Current.User
将返回null,而
HttpContext.Current.Request.IsAuthenticated
将返回false

有关如何设置User/IsAuthenticated的更多信息,请查看问题

<authentication mode="Forms">      
  <forms cookieless="UseCookies" defaultUrl="~/" loginUrl="~/user/signin" name="PMPLUSWeb" timeout="21680" slidingExpiration="true"  />
</authentication>
FormsAuthentication.RedirectFromLoginPage(userID, user.RememberMe);