Wednesday, June 9, 2010

The directive or the configuration settings profile must specify the ‘varyByParam’ attribute.

When I was trying to implement caching in an ASP.NET MVC 2 web application, I got the following error after adding the [OutputCache] attribute.

The directive or the configuration settings profile must specify the ‘varyByParam’ attribute.

As I applied the OutputCache attribute on an ActionResult method with no input parameters , I thought that the VaryByParams would be of no use in this case. But based on the error it seems that I have to specify this parameter.

So the next question is, what should I enter for a value if I have no parameters to cache against? As I found out here I have to add the magic string “none” in case you don’t have any parameters.

No comments: