Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.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
C# Redis会话在20分钟后过期,为什么?_C#_Azure_Redis_Session State - Fatal编程技术网

C# Redis会话在20分钟后过期,为什么?

C# Redis会话在20分钟后过期,为什么?,c#,azure,redis,session-state,C#,Azure,Redis,Session State,我使用redis缓存(azure服务器) 20分钟后System.Web.HttpContext.Current.Session[“UserID”]返回null 我使用Microsoft.Web.redisessionstateprovider进行自定义sesson 调用System.Web.HttpContext.Current.session[“UserID”] 调用变量时,同时更新会话变量,如下所示: var userId = System.Web.HttpContext.Current.

我使用redis缓存(azure服务器)

20分钟后
System.Web.HttpContext.Current.Session[“UserID”]
返回
null

我使用
Microsoft.Web.redisessionstateprovider
进行自定义sesson

调用
System.Web.HttpContext.Current.session[“UserID”]


调用变量时,同时更新会话变量,如下所示:

var userId = System.Web.HttpContext.Current.Session["UserID"]; // Get value 
System.Web.HttpContext.Current.Session["UserID"] = userId; // Refresh it immediately to increase timeout

未设置超时配置,默认超时配置为20分钟。 试试这个

<sessionState mode="Custom" customProvider="MySessionStateStore" timeout="120">


您所说的“滑动会话”是什么意思?您的配置中是否为会话设置了20分钟的超时?谢谢vsevold的编辑:)不,我没有。默认情况下,我假设在Redis中,它设置在
sessionState
元素上:我认为这是目前唯一要做的事情,因为它看起来不受支持。这仍然没有帮助:(
var userId = System.Web.HttpContext.Current.Session["UserID"]; // Get value 
System.Web.HttpContext.Current.Session["UserID"] = userId; // Refresh it immediately to increase timeout
<sessionState mode="Custom" customProvider="MySessionStateStore" timeout="120">