I have a C # webpage in which I store a List <> object in a server cache using HttpContext.Current.Cache. The object is cached after loading the first page. When I refresh the page, the cache object is NULL. Any thoughts?
In addition, I would like to set up a “job” to recreate the object every 30 minutes. I would like to serve the cached version until a new one is created, and then replace the old one with the new one. How to do it?
In my Global.asax, in Application_Start, I have the following:
HttpRuntime.Cache.Insert("MainADList", Uf.GetUsers(), null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
When I need it, I do the following:
MainADList = (Users)HttpRuntime.Cache["MainADList"];
This is for the most part null. Not always, but almost always.
source share