I have a wrapper class for Caching (CachingBL) where I store users that are currently signed in (some of their session info).
In CachingBL wrapper there is actually a dictionary of users, and I am putting that dictionary in cache like this: HttpContext.Current.Cache.Insert(...)
:
At the session end I would need to access to the cache like this:
var cacheBL = (CacheBL)HttpContext.Current.Cache.Get("MyCache_CacheSlot");
But the problem is that HttpContext.Current
is empty, so I cannot access the Cache
object. The Cache itself is not empty (tested), but I can't figure out how to access it at Session_End
.
Instead of putting the whole dictionary in the cache as one cache entry, put each element in the cache as an entry. Then you can give each element a sliding time window of the session timeout time, and let the system handle expiration.