Losing contents of HttpContext.Current.Cache ???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is the problem:

In Application_Start() I am setting the cache thus:

HttpContext.Current.Cache["MyObj"] = myObj;

In a subsequent page request, I am accessing the cache thus:

MyObj myObj = HttpContext.Current.Cache["MyObj"] as MyObj;

Sometimes myObj is null. How can this be?
thanks
Graham
 
Hi Graham,

Trying calling the Add method instead of using the indexer and explicitly set the expiration arguments to the desired values.
 
Back
Top