【发布时间】:2011-08-25 12:46:25
【问题描述】:
我有几个用户控件,我希望有不同的输出缓存超时。
我尝试了以下方法但没有成功:
- 设置缓存配置文件(显然只能在 aspx 页面上完成)。
-
在代码隐藏中执行以下操作:
Response.Cache.SetExpires(DateTime.Now.AddDays(OutputCaching.QuickTimeout))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(true);
Response.Cache.VaryByParams.IgnoreParams = true;
显然只有 <%@ OutputCache Duration="6000" VaryByParam="" %> 有效,但没有办法从 config- 或 appsettings 文件中获取持续时间吗?
【问题讨论】:
-
简短回答是否定的。文档说用户控件不支持缓存配置文件
标签: asp.net outputcache