如果你想将其完全关闭,你可以在你的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