2009-09-08 99 views
1

當使用@OutputCache指令,你可以定義緩存配置文件作爲在web.config中如下:ASP.NET outputCacheProfiles可以與Response.Cache一起使用嗎?

<system.web> 
    <caching> 
    <outputCacheSettings> 
     <outputCacheProfiles> 
     <add name="myprofile" duration="30" enabled="true" varyByParam="myfield"/> 
     </outputCacheProfiles> 
    </outputCacheSettings> 
    </caching> 
</system.web> 

然而,在我的應用程序,我有需要,而不是使用聲明如程序緩存一些網頁:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(5)); 
Response.Cache.SetCacheability(HttpCacheability.Public); 
Response.Cache.SetValidUntilExpires(true); 

是否可以使用Response.Cache並利用outputCacheProfiles? 例如,

Response.Cache.ApplyCacheProfile("myprofile"); 

回答

0

那麼可緩存屬性被稱爲位置,這樣你就不需要設置編程,至於其他爲什麼不嘗試一下,看看?

+0

我呼籲ApplyCacheProfile屬性()只是僞代碼。該方法不存在。我問是否存在這種方法。 – frankadelic 2010-12-24 00:56:53

0

在MVC可以使用在控制器[OutputCache(CacheProfile = "myprofile")]

相關問題