views:

45

answers:

1

In ASP.NET MVC2 I use OutputCache and the VaryByParam attribute. I got it working fine with a single parameter, but what is the correct syntax when I have several parameters on the method?

[OutputCache(Duration=30, VaryByParam = "customerId"]
Public ActionResult Index(int customerId)
{
//I've got this one under control, since it only has one parameter
}

[OutputCache(Duration=30, VaryByParam = "customerId"]
Public ActionResult Index(int customerId, int languageId)
{
//What is the correct syntax for VaryByParam now that I have a second parameter?
}

How do I get it to cache the pages using both parameters? Do I enter add the attribute twice? Or write "customerId, languageId" as the value??

+2  A: 

You can use * for all parameters or a semi-colon separated list (VaryByParam = "customerId;languageId").

You can also use none if you didn't want it to cache different versions....

Here's a nice write up specifically for MVC2.

klabranche

related questions