I want to run a consol app that calls a website on all outputcacheing pages so that all the cached paged will be cached for the user. When using the browser the page caches correctly but I want to be able to run a function that caches all the pages for the users.
Im using new System.Net.WebClient().DownloadString("http://url");
but the pages wont cache when using this call.
Cacheing attribute
[ChildActionOutputCache(("CacheAll"), Location = OutputCacheLocation.Server)]
Attribute Function
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;
}
}
web.config properties for attribute
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="CacheAll"
duration="43200"
location="Server"
varyByParam="*"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>