mercredi 18 mai 2016

How to find Key OutputCacheAttribute.ChildActionCache in mvc 3?

I have some problem:

This my action code:

[OutputCache(Duration = 3600, VaryByParam = "session")]
public PartialViewResult MiniAccountProfile(string session)
{
     //My business

     return PartialView("myPratialView", model);
}

In my PartialView, i have define enum "ActionCacheEnum.MiniAccountProfileAction" string:

<div class="menu-photo" data-cache="@ActionCacheEnum.MiniAccountProfileAction.ToString()" onclick="location.href = '/Extensions/User/Settings'">

And code find OutputCacheAttribute:

var item = OutputCacheAttribute.ChildActionCache.FirstOrDefault(x => x.Value.ToString().Contains(enumIndex));
    if (OutputCacheAttribute.ChildActionCache.Any())
    {     
         OutputCacheAttribute.ChildActionCache.Remove(ActionCacheEnum.MiniAccountProfileAction);
    }

This my idea. But i think performance its not good, because it must find into big string.

My question. How to find key of OutputCacheAttribute.ChildActionCache by ActionResult using its?

I try to using Response.RemoveOutputCacheItem, but it not work, and i read more topic example enter link description here. And They say: "Currently what you are trying to achieve is not possible in ASP.NET MVC 3. If you want to use donut output caching I would recommend you the following article. Hopefully this functionality will be added in ASP.NET MVC 4."

Thanks for helping me.

Aucun commentaire:

Enregistrer un commentaire