title: Mvc Donut Caching disable caching programmatically
body: <p>I'm using <a href="http://www.devtrends.co.uk/blog/donut-output-caching-in-asp.net-mvc-3" rel="nofollow">MvcDonutCaching</a> on my project and looking for a way to disable caching globally to assist during debugging/testing.</p>
  
  <p>I can't find any examples on how to achieve this in the documentation though I did find the <code>CacheSettingsManager</code> which exposes a <code>IsCachingEnabledGlobally</code> property however this is <code>readonly</code>.</p>
  
  <p>The <code>CacheSettingsManager</code> doesn't have any constructors which would allow me to configure this setting either. Is there a way of configuring this setting?</p>
  
  <p>There is an alternative solution which may work (ugly) but it's an absolute last resort and shouldn't really be necessary:</p>
  
  <pre><code>public class CustomOutputCache : DonutOutputCacheAttribute
  {
      public CustomOutputCache()
      {
          if(ConfigurationManager.AppSettings["UseCache"] == "false")
          {
              base.NoStore = true;
              base.Duration = 0;
          }
      }
  }
  </code></pre>
  
  <p>And then using this on my controller actions:</p>
  
  <pre><code>[CustomOutputCache]
  public ActionResult Homepage() 
  {
      // etc...
  }
  </code></pre>
  
  <p>Is there a correct way to do this?</p>