Question : System.Web.Caching.Cache Error - Object not set to an instance of an object???

HI,

I have the following 3 lines of code.  On line 2, I get the error Object reference not set to an instance of an object.  So, I create the cache, try to add something too it - and get the error.

What am I doing wrong?

ej
Code Snippet:
1:
2:
3:
Cache c = new Cache();
            c.Add("test", "test", null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 5, 0), CacheItemPriority.Normal, null);
            if (c["test"] == null) Response.Write("Null");

Answer : System.Web.Caching.Cache Error - Object not set to an instance of an object???

Cache is not a class and it is a  object which is created per application domain and it remains valid as long as the application domain remains active. Here you cannot created object from object(Cache).

Random Solutions  
 
programming4us programming4us