Session timeout is not sliding in Azure Redis Cache Session State Provider

谁说我不能喝 提交于 2019-12-05 10:11:57

Thanks you for reporting the issue. We have released a new version of RedisSessionStateProvider NuGet package that fixes above reported bug.

https://www.nuget.org/packages/Microsoft.Web.RedisSessionStateProvider/1.5.0

EDIT: We have found one more issue with this. ASP.NET doesn't call ResetItemTimeout for AJAX requests and it becomes responsibility of other session state method to slide the session timeout. We have fixed this bug and released a new NuGet package: https://www.nuget.org/packages/Microsoft.Web.RedisSessionStateProvider/1.6.5

Let us know is this resolves your issue or not?

I solved the problem of sliding expiration including the following lines in global.ascx.cs

protected void Application_AcquireRequestState()
{
    if (HttpContext.Current.Session != null)
    {
        RedisSessionStateProvider redis = new RedisSessionStateProvider();
        redis.ResetItemTimeout(HttpContext.Current, HttpContext.Current.Session.SessionID);
    }
}

You have to reset the key yourself (after you load it):

bool KeyExpire(RedisKey key, DateTime? expiry, CommandFlags flags = CommandFlags.None);
bool KeyExpire(RedisKey key, TimeSpan? expiry, CommandFlags flags = CommandFlags.None);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!