Is it possible to detect whether an ASP.NET Page is about to be cached and if so, how?
The HttpCachePolicy object provides only 开发者_如何学运维set-methods. The VaryByParams name-value collection is useless if values other than "None" and "*" are set as it impossible to enumerate them and you can only access them by key.
Additionally, I cannot use Reflection.
Any ideas?
One approach which might work if you're using ASP.NET 4.0 would be to implement your own custom OutputCacheProvider. You could then add your detection logic inside the provider.
See the MSDN ASP.NET Caching Overview for examples of adding the provider to your web.config and using the providerName attribute in your @Page or @Control directive.
精彩评论