Object reference required for non-static field, method, or property

后端 未结 3 1286
余生分开走
余生分开走 2021-01-18 22:14

I want to use the Caching.Cache(...) method, like so:

Cache.Insert(\"Interview Questions\", datatable, sqlcachedep)

or

Syst         


        
3条回答
  •  隐瞒了意图╮
    2021-01-18 22:38

    It's saying the correct thing. You should try something like:

    HttpContext.Current.Cache.Insert(...);
    

    Cache.Insert is a not a static method (static methods are indicated by an "S" near the method icon in the documentation.) You need an instance to call the Insert method on. HttpContext.Current.Cache returns the Cache object associated with the current application.

提交回复
热议问题