Question

This is an asp.net-mvc application and I am trying to add an object, specifically a list of user objects to the cache. I feel like I'm missing a key concept or component when it comes to caching data, so any help would be greatly appreciated.

 var cache = new Cache();

 cache["Users"] = users;

The second line throw's "Object reference not set to an instance of an object. The users variable is not null, I'm certain I'm not creating or using the cache correctly, but cannot find any information in MSDN or SO regarding the right way to set up a cache. What's my mistake?

Était-ce utile?

La solution

try using Cache Like this it may works if you are using static methods

System.Web.HttpContext.Current.Cache
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top