Vnuk
Vnuk

Reputation: 2703

HttpContext.Current is null when CacheItemRemovedCallback is raised

I have code in global.asax that sets some things in cache with CacheItemRemovedCallback.

When item is removed from cache, method in CacheItemRemovedCallback is raised.

The problem is, it cannot update the item in cache because HttpContext.Current is null (therefor Cache cannot be accessed).

Is there a workaround for this or am I doing this entirely wrong?

Framework is 3.5

Upvotes: 4

Views: 1442

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189505

You can access the Cache from the HttpRuntime type:-

HttpRuntime.Cache.Add( ... );

Upvotes: 7

Related Questions