DonutCache is not removing cache for child action

Oct 29, 2013 at 11:55 AM
i am using DonutCaching to cache ChildActionOutput and its working fine but when i am trying to remove the object from cache it not removing it.

i have gone through many post but it didnt work.

posts : http://forums.asp.net/t/1763188.aspx DonutOutputCache is not clearing cache when using variable

My Code

[DonutOutputCache(Duration = 600, VaryByParam = "trainerid")]
public ViewResult ProfileContainer(int trainerid)
{
    var model = new ProfileContainerViewModel {TrainerId = trainerid};
    return View("Profile/ProfileContainerPartial", model);
}
"Profile/ProfileContainerPartial" view further contains many child action and i am assuming that if we cache the parent view it will by default cache inner views.

but when i am refreshing the cache it not working

below is the code to refresh the cache

[Authorize]
[HttpPost]
public JsonResult MyProfile(EditProfileRequestModel requestModel)
{
    var cacheManager = new OutputCacheManager();
    cacheManager.RemoveItem("TrainerProfileContainer", "Account");
    RegistrationAccessor.ClearRegistrationCached(requestModel.Id);
    var output = AjaxResult.GetSuccessAjaxResult("");
    output.ReturnedObject =
        new
        {
            Message = "Profile Updated Successfully"
        };
    return Json(output);
}