小编Sha*_*ain的帖子

使用VaryByCustom使缓存无效

我想使用VaryByCustom属性使缓存无效.以下代码用于缓存设置.

public override string GetVaryByCustomString(HttpContext context, string arg)
{
    if (!string.IsNullOrWhiteSpace(arg))
    {
        if (context.User.Identity.Name != null)
        {
            return context.User.Identity.Name;
        }
    }
    return base.GetVaryByCustomString(context, arg);
}
Run Code Online (Sandbox Code Playgroud)

c# caching cache-invalidation asp.net-mvc-4

5
推荐指数
1
解决办法
141
查看次数

标签 统计

asp.net-mvc-4 ×1

c# ×1

cache-invalidation ×1

caching ×1