Reputation: 875
As per MSDN: "One instance of this class is created per application domain, and it remains valid as long as the application domain remains active. Information about an instance of this class is available through the Cache property of the HttpContext
object or the Cache
property of the Page
object."
As per my knowledge, HttpContext
and Page
Object life is valid for single http request. So what is the use of Cache Property (Data caching) when I cant use it for another request?
Upvotes: 2
Views: 94
Reputation: 46919
HttpContext
and Page
might only be valid on a request basis. The cache however is on application level. Just because you can access the Cache object using HttpContext
and Page
does not mean they have the same lifespan.
Upvotes: 1
Reputation: 164291
MSDN is correct: HttpContext.Cache
lives for your entire application lifecycle, not just over a request.
You are correct that the HttpContext
lives per request, but the Cache
object lives over the entire application life. The framework makes sure to assign the correct Cache
instance whenever creating an HttpContext
for you.
Upvotes: 4