开发者

Setting CacheProfile in HttpHandler

开发者 https://www.devze.com 2022-12-12 00:02 出处:网络
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?

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

精彩评论

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

关注公众号