Normally i have a static class that reads and writes to HttpContext.Current.Cache
However since adding threading to my project, the threads all get null reference exceptions when trying to retrieve this object.
Is there any other way i can access it, workarounds or another cache i can use?
System.Web.Caching.Cacheis thread-safe. Nolockneeded here.HttpContext.Currentis thread-local and read-only so basically, yes, it is thread-safe, although it's also wrong for the reasons pointed out by binarycoder below.HttpRuntime.Cacheis the same, but globally-accessible; it's not synchronized but it's also immutable, so you don't need to use any explicit locks. In fact, the ASP.NETHttpContext.Cacheis just a reference toHttpRuntime.Cache, so it has to be thread-safe, otherwise ASP.NET requests would steamroll each other constantly.