Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable OutputCaching in MVC3 when running in DEBUG or under Debugger?

I am trying to disable output caching in a MVC3 app when in debug. I am specifying output caching in the controllers (via the attribute) but don't want to have to #if DEBUG all over my code. I expected this to work:

// In Web.config.debug
  <system.web>
    <caching>
      <outputCache enableOutputCache="false"
                   xdt:Transform="Replace" />
    </caching>

But this seems to be ignored. Any other ideas how to do it system wide without nasty global.asax code or #if DEBUGs everwhere?

like image 774
Shawn Wildermuth Avatar asked Mar 13 '11 02:03

Shawn Wildermuth


1 Answers

The web.config.debug file is used only when you build a deployment package. If you run your site locally in Cassini for example it is completely ignored. So you may try disabling cache in your web.config:

<system.web>
    <caching>
        <outputCache enableOutputCache="false" />
    </caching>
</system.web>

and in your web.config.release enable the cache. Note though that if you don't use the web deployment package feature those files are completely ignored.

like image 158
Darin Dimitrov Avatar answered Oct 21 '22 00:10

Darin Dimitrov