Reputation: 11731
I have an ActionResult which i want it to be cached based on the id
[DonutOutputCache(Duration = 3600, VaryByParam = "product_Id")]
public ActionResult ProductInfo(Guid product_Id)
{
System.Threading.Thread.Sleep(3000);
return PartialView(_repository.GetProductInfo(product_Id));
}
It is working good.
When i want to remove the cache, i use this syntax
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveDetails(DetailsModel model)
{
try
{
// save action here, then remove cache
var cacheManager = new OutputCacheManager();
cacheManager.RemoveItem("Common", "ProductInfo", new { product_Id = model.Product_Id });
return Json(new { hasError = false }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(new { hasError = true, message = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
OutputCacheManager().RemoveItem doesn't work when i specify a parameter.
It works if i just use
cacheManager.RemoveItem("Common", "ProductInfo");
What am i doing wrong?
Upvotes: 4
Views: 1853
Reputation: 11731
I found the solution
it seems that the parameter can't contain uppercase letters. This is a known bug which will be fixed.
Change product_Id to product_id and it will work.
Upvotes: 3