I need to utilize the Cache object in ASP.NET to store some data with a file dependency but I can’t have it available to the rest of the application. There could be some security violations if someone set the cache item to something different.
I couldn’t find a way to say the cache item is private to my assembly.
I was expecting to be able to create my own new Cache(), but checking for a value, mycache[“Value”] != null, is throwing an null reference exception from the inards of the object. I’m assuming because the Server.Cache object is created with some other stuff that initializes the Cache object correctly.
Does anyone know how I can make an item private, or initialize my own Cache object?
EDIT: Inserting an item also throws a null reference exception. mycache.Insert(“item”, true)
If you mean private in the sense that you’re creating a component that you will distribute to other programmers, and you want to cache stuff with your component but hide the cache item details that you’re caching from programmer’s prying eyes, you can’t use Cache that way.
You can encrypt your cache items though. Providing your encryption scheme is secure, programmers will be able to override your cached items, but you will always be the only one who can decrypt your encrypted values. If decryption fails, then you know that the cache has been tampered with.