开发者

How to detect (with server-side code) whether an ASP.NET Page is about to be cached (the first time it is requested)?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜