Using System.Web.Caching.Cache

Viewed 36529

I am trying to use the Cache, but get the error below. How can I properly use the Cache?

protected void Page_Load(object sender, EventArgs e) {
x = System.DateTime.Now.ToString();
 if (Cache["ModifiedOn"] == null) { // first time so no key/value in Cache
    Cache.Insert("ModifiedOn", x); // inserts the key/value pair "Modified On", x            
 }
 else { // Key/value pair already exists in the cache
     x = Cache["ModifiedOn"].ToString();
 } }

'System.Web.Caching.Cache' is a 'type' but is used like a 'variable'

2 Answers
Related