I m having a webService.
In that I m using Caching.

I have wrote following code to 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 like "An object Reference is required for non static field.

How can i remove this error

I got My answer.

I used HttpContext.Current.Cache

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.