如果你想將其完全關閉,你可以在你的web.config under.system.web使用
<caching>
<outputCache enableOutputCache="false" />
</caching>
。如果你想從代碼做到這一點(使用按鈕或別的東西),你也可以這樣做:
System.Configuration.Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
System.Web.Configuration.OutputCacheSection cacheSection = (System.Web.Configuration.OutputCacheSection)config.GetSection("system.web/caching/outputCache");
cacheSection.EnableOutputCache = true/false;
config.Save();
這將可能只有您的開發機器上工作。大多數服務器都設置爲不允許編輯machine.config中的該部分。
您不能爲偏數執行此操作。 – 2012-12-06 14:47:02