How do you use an ASP.NET Cache object in an ASP.NET application?

I would like to use the System.Web.Caching.Cache object in my application, but this code throws a NullReferenceException.

Cache cache = new Cache(); cache["key"] = new object(); 

Any ideas?

Update

HttpRuntime.Cache solves my problem, but does anyone have a solution to use multiple cache instances in my application?

+4
source share
2 answers

Use the static property HttpRuntime.Cache ; It works great.

+4
source

Caching applications for enterprise libraries can help you. It is great for Windows applications as well as ASP.NET applications.

+2
source

All Articles