2010-08-21 3 views
85

ASP.NET MVC2에서 나는 OutputCacheVaryByParam 속성을 사용합니다. 단일 매개 변수를 사용하여 올바르게 작동하게했지만 메서드에 여러 매개 변수가있을 때 올바른 구문은 무엇입니까?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? 
} 

두 매개 변수를 모두 사용하여 페이지를 캐시하려면 어떻게합니까? 속성을 두 번 추가 하시겠습니까? 또는 "customerId, languageId"를 값으로 씁니다.

답변

171

모든 매개 변수에 *를 사용하거나 세미콜론으로 구분 된 목록 (VaryByParam = "customerId;languageId")을 사용할 수 있습니다.

당신이 다른 버전을 캐시하지 않은 경우 당신은 또한 없음을 사용할 수 없습니다 ....

Here's a nice write up specifically for MVC.

+0

링크가 작동하지 않습니다. – Espo

+1

링크가 업데이트되었습니다. :-) – klabranche