0

aspx ファイルでは、CacheProfile を Web.Config で定義された特定のプロファイルに設定できます。これを HttpHandler でどのように行うのですか?

キャッシュを使用できることは知っていますが、Web.Config からキャッシュ プロファイルを使用できますか?

4

1 に答える 1

1

私が見つけた唯一の方法は、構成からプロファイルを読み取り、プログラムで適用することです。

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...
于 2009-11-18T14:48:43.777 に答える