title: ASP.NET Object Caching in a Class
body: <p>I'm trying to create a Caching Class to cache some objects from my pages. The purpose is to use the Caching system of the ASP.NET framework but to abstract it to separate class.
  It seems that the caching doesn't persist.</p>
  
  <p>Any ideas what I'm doing wrong here? Is it possible at all to cache object out side the Page it self?</p>
  
  <p>EDIT: added the code:</p>
  
  <p>Insert to cache</p>
  
  <pre><code>Cache c = new Cache();
  c.Insert(userid.ToString(), DateTime.Now.AddSeconds(length), null, DateTime.Now.AddSeconds(length), Cache.NoSlidingExpiration,CacheItemPriority.High,null);
  </code></pre>
  
  <p>Get from the cache</p>
  
  <pre><code>DateTime expDeath = (DateTime)c.Get(userid.ToString())
  </code></pre>
  
  <p>I get null on the c.Get, even after I did have the key.</p>
  
  <p>The code is in a different class than the page itself (the page uses it)</p>
  
  <p>Thanks.</p>