OutputCacheProfile 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
配置可由应用程序页使用的输出缓存配置文件。 此类不能被继承。
public ref class OutputCacheProfile sealed : System::Configuration::ConfigurationElement
public sealed class OutputCacheProfile : System.Configuration.ConfigurationElement
type OutputCacheProfile = class
inherit ConfigurationElement
Public NotInheritable Class OutputCacheProfile
Inherits ConfigurationElement
- 继承
示例
下面的代码示例演示如何使用 OutputCacheProfiles 集合访问其 OutputCacheProfile 对象。
// Get the Web application configuration.
System.Configuration.Configuration webConfig =
WebConfigurationManager.OpenWebConfiguration("/aspnetTest");
// Get the section.
string configPath =
"system.web/caching/outputCacheSettings";
System.Web.Configuration.OutputCacheSettingsSection outputCacheSettings =
(System.Web.Configuration.OutputCacheSettingsSection)webConfig.GetSection(
configPath);
// Get the profile at zero index.
System.Web.Configuration.OutputCacheProfile outputCacheProfile =
outputCacheSettings.OutputCacheProfiles[0];
' Get the Web application configuration.
Dim webConfig _
As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration( _
"/aspnetTest")
' Get the section.
Dim configPath As String = _
"system.web/caching/outputCacheSettings"
Dim outputCacheSettings _
As System.Web.Configuration.OutputCacheSettingsSection = _
CType(webConfig.GetSection(configPath), _
System.Web.Configuration.OutputCacheSettingsSection)
' Get the profile at zero index.
Dim outputCacheProfile _
As System.Web.Configuration.OutputCacheProfile = _
outputCacheSettings.OutputCacheProfiles(0)
注解
该OutputCacheProfile类提供了一种以编程方式访问和修改add
配置文件节中caching
节的元素outputCacheProfiles
的方法。
该 OutputCacheProfile 对象集中常用的配置设置,例如依赖项、缓存位置和缓存过期时间,无需在每个页面上指定它们。
OutputCacheProfile可以使用指令的属性@ OutputCache
将该属性应用于页面CacheProfile
。
备注
该 @ OutputCache
指令可以重写对象包含 OutputCacheProfile 的所有设置,但属性除外 Enabled 。 这是启用或禁用 OutputCacheProfile 它,而无需修改可能覆盖它的所有页面中的指令。
该 CacheDependency 类监视依赖项,以便在任何缓存项发生更改时自动删除缓存的项。
构造函数
OutputCacheProfile(String) |
初始化 OutputCacheProfile 类的新实例。 |