I'm trying to use cache profiles for caching child actions in my mvc application, but I get an exception: Duration must be a positive number.
My web.config looks like this:
<caching>
<outputCache enableOutputCache="true" />
<outputCacheSettings>
<outputCacheProfiles>
<add name="TopCategories" duration="3600" enabled="true" varyByParam="none" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
And my child action something like this:
[ChildActionOnly]
[OutputCache(CacheProfile = "TopCategories")]
//[OutputCache(Duration = 60)]
public PartialViewResult TopCategories()
{
//...
return PartialView();
}
Inside a view I just call @Html.RenderAction("TopCategories", "Category")
But I get an error:
Exception Details: System.InvalidOperationException: Duration must be a positive number.
If I don't use cache profile it works. Have an idea what's the problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…