Caching in ASP.net -


i m having webservice. in m using caching.

i have wrote following code store datatable in cache.

using system.web.caching;  cache.insert("dt", dt, null, datetime.now.addhours(1), timespan.zero, system.web.caching.cacheitempriority.default, null); 

it give me error "an object reference required non static field.

how can remove error

you're trying use cache class static one.

if want use current cache class instance http context during request, should doing like:

httpcontext.current.cache.insert("dt", dt, null, datetime.now.addhours(1), timespan.zero, system.web.caching.cacheitempriority.default, null); 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

java - netbeans "Please wait - classpath scanning in progress..." -

openxml - Programmatically format a date in an excel sheet using Office Open Xml SDK -