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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top