【发布时间】:2013-10-12 08:13:04
【问题描述】:
我正在为我的 ASP.NET 应用程序使用 DevTrends.MvcDonutCaching 包,它运行良好。我目前遇到的一个问题是我为子操作设置的 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>
任何帮助将不胜感激。
谢谢。
【问题讨论】:
标签: c# asp.net asp.net-mvc-4 caching