On my website I want the user to have the ability to login/logout from any page. When the user select login button a modal dialog will be present to the user for him to enter i
I got around the problem by creating a custom OutputCache
attribute, that manually loads the Duration
, VarByCustom
and VarByParam
from the profile:
public class ChildActionOutputCacheAttribute : OutputCacheAttribute
{
public ChildActionOutputCacheAttribute(string cacheProfile)
{
var settings = (OutputCacheSettingsSection)WebConfigurationManager.GetSection("system.web/caching/outputCacheSettings");
var profile = settings.OutputCacheProfiles[cacheProfile];
Duration = profile.Duration;
VaryByParam = profile.VaryByParam;
VaryByCustom = profile.VaryByCustom;
}
}
The advantage of this approach is that you get to still keep all your profiles in just one place in the web.config.
This is also posted in the related question: https://stackoverflow.com/a/13866280/1373170