views:

1224

answers:

1

I encountered the above error message after applying the OutputCache attribute on ActionResult methods with no input parameters - why would I use VaryByParams in this case? Is this a bug in ASP.Net MVC or is there a way of using OutputCache without setting this property?

My big question is, if I have to use VaryByParams, what should I enter for a value if I have no parameters to cache against?

+13  A: 

I never found a satisfactory answer for this - basically, you just need to add the VaryByParams property and if you don't have any parameters set it to the magic string "none".

http://msdn.microsoft.com/en-us/library/system.web.ui.outputcacheparameters.varybyparam.aspx

Zac
Not an empty string. According to MSDN, if no parameters are to be used, the value of VaryByParam should be "none": http://msdn.microsoft.com/en-us/library/system.web.ui.outputcacheparameters.varybyparam.aspx
bzlm
Ah, that's useful to know - I guess that's the problem with good ol' magic strings eh?
Zac