views:

20

answers:

2

Is it possible to iterate the OutputCache keys? I know you can remove them individually via HttpResponse.RemoveOutputCacheItem(), but is there a way I can iterate all the keys to see what's in the collection?

I searched through Object Viewer, but didn't see anything.

Worst case, I can maintain my own index. Since I'm doing everything by VaryByCustom, they get "fed" through a method in global.asax. It just strikes me that there has to be a more elegant way of doing this.

A: 

I have use this

http://www.codeproject.com/KB/session/exploresessionandcache.aspx

to view the cache and the session data. I only have to say that show only one pools data. If you have more pools, then you just see the one you are on it.

Aristos
A: 

If you're using ASP.NET 4.0 you could do this by writing your own OutputCacheProvider. That would give you the ability to store the keys at the point that the item is cached:

namespace StackOverflowOutputCacheProvider
{
    public class SOOutputCacheProvider: OutputCacheProvider
    {
        public override object Add(string key, object entry, DateTime utcExpiry)
        {
            // Do something here to store the key

            // Persist the entry object in a persistence layer somewhere e.g. in-memory cache, database, file system

            return entry;
        }

        ...

    }
}

You'd then be able to read the keys out from wherever you've stored them.

PhilPursglove