在ASP.NET MVC2我用OutputCache
和VaryByParam
属性。我得到它的工作罚款与一个单一的参数,但什么是我对法的几个参数的正确语法?
[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?
}
我如何得到它使用缓存两个参数的页面?难道我进入添加属性两次?或者写“客户ID,languageId”的价值?
您可以使用*对所有参数或分号分隔列表(VaryByParam = "customerId;languageId"
)。
您也可以使用没有,如果你不希望它缓存不同的版本....
您还可以使用*
包括所有参数
[OutputCache(Duration =9234556,VaryByParam = "*")]