I am new to MVC, and I have a project to convert from MVC2 to the latest version of MVC. I read several books about MVC 4, so I began to understand the basic mechanisms.
However, when converting my MVC 2 solution, I have a problem with the attribute: OutputCache .
E.g. I have several such actions (attributes may vary):
[OutputCache(CacheProfile = "ProductImage")] public ActionResult GetImage(Guid elementId, int imgtype)
in Web.Config I have in "caching> outputCacheSettings> outputCacheProfiles>":
<add name="ProductImage" duration="5" varyByParam="elementId,imgtype" />
and resulting in the following exception:
OutputCacheAttribute for child actions only supports duration, VaryByCustom and VaryByParam. Please do not set CacheProfile, Location, NoStore, SqlDependency, VaryByContentEncoding or VaryByHeader Values ββfor child actions.
As I understand it, the problem occurs only with child actions.
- Is there any other way to have a cache profile in the latest MVC?
- Is there a way to determine if an action is a child, to change only that action?
Serge source share