Я использую пакет DevTrends.MvcDonutCaching для моего приложения ASP.NET, и он отлично работает. Одна из проблем, которые у меня есть на данный момент, - это недействительность кэша VaryByCustom, который я настроил для дочернего действия.Как аннулировать кеш с помощью ASP.NET MVC 4.0 DonutOutputCache VaryByCustom
Вот код, который я для установки VaryByCustom:
public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg == "userlogin" && context.User.Identity.IsAuthenticated)
{
return "UserLogin=" + context.User.Identity.Name;
}
return base.GetVaryByCustomString(context, arg);
}
Вот как украшено мое действие:
[Authorize]
[DonutOutputCache(Duration = 3600, VaryByCustom = "userlogin")]
public ActionResult UserProfile()
{ ... }
И это, как я пытался очистить этот кэш (я пробовал без каких-либо параметров и с «userlogin», но ни один из них не работал:
OutputCacheManager om = new OutputCacheManager();
om.RemoveItem("Customer", "UserProfile", new { UserLogin = User.Identity.Name });
Это бритва вид детали:
<div id="cabinetMain">
@{Html.RenderAction("UserProfile", true);}
</div>
Любая помощь будет очень признательна.
Спасибо.