注意:這個類別是 .NET Framework 2.0 版的新功能。
設定可由應用程式頁面使用的輸出快取設定檔。這個類別無法被繼承。
命名空間: System.Web.Configuration
組件: System.Web (在 system.web.dll 中)
Public NotInheritable Class OutputCacheProfile
Inherits ConfigurationElement
Dim instance As OutputCacheProfile
public sealed class OutputCacheProfile : ConfigurationElement
public ref class OutputCacheProfile sealed : public ConfigurationElement
public final class OutputCacheProfile extends ConfigurationElement
public final class OutputCacheProfile extends ConfigurationElement
OutputCacheProfile 類別提供以程式方式,存取和修改組態檔 caching 區段中 outputCacheProfiles 區段的 add 項目。
OutputCacheProfile 物件集中化常用的組態設定,例如,相依性、快取位置及快取過期時間,讓您不需在每個頁面上逐一指定。
使用 @ OutputCache 指示詞的 CacheProfile 屬性,可將 OutputCacheProfile 套用至頁面。
注意事項 |
|---|
| @ OutputCache 指示詞可以覆寫除了 Enabled 屬性以外,包含在 OutputCacheProfile 物件中的所有設定。這是為了啟用或停用 OutputCacheProfile,而不需要在可能將之覆寫的所有頁面中修改指示詞。 |
CacheDependency 類別會監視相依性,如此當任何快取項目變更時,該快取項目就會自動移除。
下列程式碼範例示範如何使用 OutputCacheProfiles 集合來存取其 OutputCacheProfile 物件。
' 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)
// 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];
System.Object
System.Configuration.ConfigurationElement
System.Web.Configuration.OutputCacheProfile
這個型別的所有公用靜態成員 (即 Visual Basic 中的 Shared 成員) 都是安全執行緒。並非所有的執行個體成員均為安全執行緒。
Windows 98、 Windows 2000 SP4、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
.NET Framework
支援版本:2.0