"CacheProfile" in MVC 5

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?
+6
source share
2 answers

It was decided to install MvcDonutCaching nuget and replace [OutputCache with [DonutOutputCache ...

More about more .

+3
source

Read the answer to this question , I believe that it answers your question very well.

0
source

All Articles