2011-11-15 78 views
5

我有一個擁有輸出緩存(部分輸出緩存)的控件的頁面。這些設置是這樣的:清除部分輸出緩存

[PartialCaching(86400, null, null, "campaign.whatwhere", true)] 
public partial class controls_LatestEnquiriesListCached : System.Web.UI.UserControl 
{ 

... 

隨着

public override string GetVaryByCustomString(HttpContext context, string custom) 
{ 
    if (custom == "campaign.whatwhere") 
    { 
     return (CampaignManager.CurrentCampaign.DefaultWorkTypeId ?? 0).ToString() + (CampaignManager.CurrentCampaign.DefaultEnquiryAreaId ?? 0).ToString(); 
    } 
    return base.GetVaryByCustomString(context, custom); 
} 

Global.asax

我如何設置這樣我就可以在特定頁面上清除這個輸出緩存?

是否可以像MyPageWithCachedControl.aspx?ClearCache=true那樣設置?

+0

http://stackoverflow.com/questions/565239/any-way-to-clear-flush-remove-outputcache – Ramesh

+0

另外http://stackoverflow.com完全重複/ questions/37101/how-to-clear-outputcache-for-website-without-restarting-app – Ramesh

+0

這些確切的重複如何? –

回答

0

您可以創建一個aspx頁面,它除了清除緩存外什麼也不做。您可以使用querystring參數並通過緩存鍵刪除它。

或者您可以嘗試查找和ASP.NET緩存管理器。

0

使用HTTPResponse.RemoveOutputCacheItem(pathofpage)指定清除某個特定頁面的緩存路徑是用戶控制的虛擬絕對路徑。

例如:

private void Button1_Click(object sender, System.EventArgs e) 
{ 
    HttpResponse.RemoveOutputCacheItem("/form1.aspx"); 
}