Redis Session State Provider Does Not Delete Keys in Abandon Session

I save session state in azure redis cache using this .

NuGet RedisSessionStateProvider saves session state in Redis, and you can manage it since it was a clasiccal inProc Session.

When the user logs in, I do something like this:

AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
Session.Add("key", "value");

A session value is created all the time in the application. If you look at your REDIS cache, you will see these two keys snurztvlyl2jk5wnzstjikln_Internal snurztvlyl2jk5wnzstjikln_Data, where snurztvlyl2jk5wnzstjiklnis the SessionID.

When I write out:

public ActionResult LogOff()
{
Session.Abandon();
AuthenticationManager.SignOut();
return RedirectToAction("Index", "Home");
}

The user is SignOut, but if I look at the redis cache, the values ​​are saved. They are not deleted and are deleted only after a session timeout. I also tried Session.Clear()and the keys in the Redis cache are still stored.

Why are the keys not deleted or what am I doing wrong?

. , . https://github.com/ricardopolo/RedisIssue

+4
2

NuGet RedisSessionStateProvider, .

:

Logout, "Session.Abandon()". Redis, RedirectToAction ( "", "" ) "GetItemExclusive" ( state provider), , "CreateUninitializedItem", SessionStateActions InitializeItem ( 1). , , HGETALL , "SessionStateActions" "". , .

ASP.NET MVC. . (http://msdn.microsoft.com/en-us/library/ms178587(v=vs.140).aspx) .

+5

. Session.Abandon() , ResetItemTimeout (* _Internal). , Redis. * _, Session.Abandon(), .

, * _Internal, nuget. (https://www.nuget.org/packages/Microsoft.Web.RedisSessionStateProvider/1.3.0)

, .

+2

Source: https://habr.com/ru/post/1569018/


All Articles