I would like the OutputCache feature to be disabled if the system.web.compilation setting in the web.config is set to debug="true".
I can successfully access this value by calling this method in my Global.asax's Application_Start():
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
CompilationSection configSection = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
if (configSection?.Debug == true)
{
filters.Add(new OutputCacheAttribute()
{
VaryByParam = "*",
Duration = 0,
NoStore = true
});
}
}
The problem is, any endpoints in my controllers that have OutputCache explicitly set will not use the global filter that was set up.
[OutputCache(CacheProfile = "Month")]
[HttpGet]
public ViewResult contact()
{
return View();
}
Here is where that "Month" profile is defined in my web.config:
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="Month" duration="2592000" location="Any" varyByParam="*" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
I need to be able to nullify the use of explicitly defined OutputCache profiles, like "Month", when I'm in debugging mode. How can I do this?

