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該區段outputCacheProfiles的元素caching。
該 OutputCacheProfile 物件集中管理常用的設定,如相依關係、快取位置及快取過期時間,免除在每頁指定這些設定的需求。
可 OutputCacheProfile 利用 CacheProfile 指令的 @ OutputCache 屬性套用到頁面。
Note
指令 @ OutputCache 可以覆寫物件所包含 OutputCacheProfile 的所有設定,唯獨屬性除外 Enabled 。 這是為了啟用或停用 , OutputCacheProfile 而不必修改所有可能覆蓋該指令的頁面指令。
該 CacheDependency 類別監控相依關係,因此當快取項目有變動時,該快取項目會自動被移除。
建構函式
| 名稱 | Description |
|---|---|
| OutputCacheProfile(String) |
初始化 OutputCacheProfile 類別的新執行個體。 |