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

I want to use the Caching.Cache (...) method, for example:

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

or

System.Web.Caching.Cache.Insert("Reading List", datatable, sqlcachedep);

There are no problems with variables, but I get this error message anyway:

Error 1 - an object reference is required for a non-static field, method or property "System.Web.Caching.Cache.Insert (string, object, System.Web.Caching.CacheDependency)"

How can i fix this?

thanks

+5
source share
3 answers

He says the right thing. You should try something like:

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

Cache.Insert - ( "S" .) Insert. HttpContext.Current.Cache Cache, .

+16

Page.Cache.Insert()

( , ASP.Net). Cache , .

+1

( ):

HttpApplication.Context.Cache.Insert("Reading List", datatable, sqlcachedep);
+1

All Articles