문제

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?

도움이 되었습니까?

해결책

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

System.Web.HttpContext.Current.Cache
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top