开发者

Setting CacheProfile in HttpHandler

In an aspx file you can set the 开发者_Python百科CacheProfile to a certain profile defined in Web.Config. How do you do this in a HttpHandler?

I know you can use Cache but can you use Cache Profiles from Web.Config?


The only way I have found is to read the profile from the config and apply it programmatically:

var settings = (OutputCacheSettingsSection)
  WebConfigurationManager.GetSection("system.web/caching/outputCacheSettings");
var profile = settings.OutputCacheProfiles["ProfileName"];
var cachePolicy = context.Response.Cache;
//Set up your caching here using the profile
cachePolicy.SetExpires(context.Timestamp.AddSeconds(profile.Duration));
//And so on...
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜