How can I access HTTP Cache in a C# class library ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is recommended that you use
System.Web.HttpRuntime.Cacherather thanSystem.Web.HttpContext.Current.Cache, as explained in this article.Additionally, while the article talks about performance, I’ve also had issues in the past where
HttpContext.Currentisn’t always available when you’d expect it to be, especially when dealing with asynchronous handlers.Another thing to note is that if you aren’t accessing the cache in the context of an HTTP request,
HttpContextwon’t help you, since there won’t be a relevant context for you to access.