在调试时,我正在尝试禁用MVC3应用程序中的输出缓存。我在控制器中指定了输出缓存(通过属性),但我不想让#if DEBUG遍及我的代码。我原以为这能行得通:
// In Web.config.debug
<system.web>
<caching>
<outputCache enableOutputCache="false"
xdt:Transform="Replace" />
</caching>
但这一点似乎被忽视了。有没有其他的想法,如何在没有讨厌的global.asax代码或#if DEBUGs的情况下在系统范围内做到这一点?
发布于 2011-03-13 18:01:57
只有在构建deployment package时才会使用web.config.debug
文件。例如,如果您在Cassini中本地运行您的站点,它将被完全忽略。因此您可以尝试在web.config
中禁用缓存
<system.web>
<caching>
<outputCache enableOutputCache="false" />
</caching>
</system.web>
并在您的web.config.release
中启用缓存。但是请注意,如果您不使用web部署包特性,这些文件将被完全忽略。
发布于 2020-01-10 16:53:56
如果使用IIS版本7以上,则应:
<system.webServer>
<caching enabled="true"/> //false in webconfig.debug
</system.webServer>
https://stackoverflow.com/questions/5287005
复制相似问题