I try to cache a call to an action method in ASP.NET MVC3 RC1.
The caching works, but the variation by parameter doesnt seem to pick up. Is there something I can do to make the 3 calls to HotOffers return different results depending on productID?
The output right now is
Hot offers 4
Hot offers 4
Hot offers 4
I want the output to be
Hot offers 4
Hot offers 6
Hot offers 8
Action
[OutputCache(Duration = 100, VaryByParam = "productId")]
public PartialViewResult HotOffers(int productId)
{
ProductModel model = new ProductModel { ProductID = productId };
model.Name = "Meatball";
return PartialView(model);
}
Page (Index.cshtml)
@{
View.Title = "Home Page";
}
<p>
<div>
@Html.Action("HotOffers", new { productid=4})
</div>
<div>
@Html.Action("HotOffers", new { productid=6})
</div>
<div>
@Html.Action("HotOffers", new { productid = 8 })
</div>
</p>
Partial (HotOffers.cshtml)
Hot offers
@Model.ProductID