I have a simple partial view that I'm rendering in my main view with:
@Html.Action("All", "Template")
On my controller I have this:
[OutputCache(CacheProfile = "Templates")]
public ActionResult All()
{
return Content("This stinks.");
}
And in my config this:
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<clear/>
<add name="Templates" duration="3600" varyByParam="none"/>
</outputCacheProfiles>
</outputCacheSettings>
<outputCache enableOutputCache="false" enableFragmentCache="false" />
</caching>
This will fail at runtime with exception:
Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper
And inner exception:
Duration must be a positive number
Now obviously it's not picking up my web.config settings, because if I change it to:
[OutputCache(Duration = 3600)]
It will work, but also notice in my web.config I turned off enableOutputCache and enableFragmentCache, but it doesn't honor these settings.
Curiously, in a normal view these settings work fine, so what is it about partial views that is breaking this? Am I missing something? The Gu says this should work just fine... In short, is it supposed to honor caching settings in web.config and if not, why not?