If so how do I get a hold of the Cache object?
开发者_JAVA百科I tried declaring a static Cache object in my controller (hoping it will not be disposed too frequently) like so:
private static readonly System.Web.Caching.Cache cache = new System.Web.Caching.Cache();
As soon as I call cache["MyObject"] I get a nullReference at System.Web.Caching.Cache.Get(String key) (did the old ASP.Net Page class catch that? yuck!)
I need caching with a file dependency.
You should not create a brand new Cache object, you need to retrive it from HttpContext like this: HttpContext.Cache
精彩评论