|
|
|
|
|
|
CacheProfile是OutputCache緩存的一個參數,用于定義與該頁關聯的緩存設置的名稱。是可選屬性,默認值為空字符("")。
需要注意的是,包含在用戶控件中的@ OutputCache指令不支持此屬性。在頁面中指定此屬性時,屬性值必須與Web.config文件<outputCacheSettings>配置節下的outputCacheProfiles元素中的一個可用項的名稱匹配。如果此名稱與配置文件項不匹配,將引發異常。
CacheProfile 屬性
獲取或設置 OutputCacheProfile 名稱,該名稱與輸出緩存項的設置關聯。
命名空間: System.Web.UI
程序集: System.Web(在 System.Web.dll 中)
◇語法:
Public Property CacheProfile As String
1. public string CacheProfile { get; set; }
public:
property String^ CacheProfile {
String^ get ();
void set (String^ value);
}
member CacheProfile : string with get, set
◇屬性值
類型: SystemString
與輸出緩存項的設置關聯的 OutputCacheProfile 名稱。
◇備注
配置文件標識 <outputCacheSettings> 配置中的一組緩存設置(用作輸出緩存項的基本設置)。
◇版本信息
.NET Framework
受以下版本支持:4.5、4、3.5、3.0、2.0
◇平臺
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(不支持服務器核心角色), Windows Server 2008 R2(支持帶 SP1 或更高版本的服務器核心角色;不支持 Itanium)
.NET Framework 并不是對每個平臺的所有版本都提供支持。
示例:
<%@ OutputCache CacheProfile="Cache30Seconds" %>
配置:
Web.config
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="Cache30Seconds" duration="30"
varyByParam="none" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
Add節里面的各個屬性和OutPutCache相對應
注意:
OutputCache生命優先于outputCacheProfiles配置,比如:OutputCache頁面緩存10s,outputCacheProfiles設置緩存20s,則最后緩存10s。查看OutputCache緩存使用的詳細介紹。
