zoukankan      html  css  js  c++  java
  • 清除用户控件的缓存

    在global.assx中重写如下方法:
     public override string GetVaryByCustomString(HttpContext context, string arg)
            {
                if (arg == "news_ascx")
                {
                    string value= HttpRuntime.Cache["news_ascx"];
                    if (value == null)
                    {

                        value = DateTime.Now.ToString();           
                     HttpRuntime.Cache.Insert("", value, null, DateTime.MaxValue, new TimeSpan(100,0,0,0),CacheItemPriority.Normal, null);

                    }
                    return value;
                }
                return base.GetVaryByCustomString(context, arg);
            }
    在用户控件中News.ascx中添加如下属性

    <%@ OutputCache Duration="86400" VaryByCustom="news_ascx" VaryByParam="none"  %>

    在需要移除用户控件缓存的地方添加如下代码:
     Cache.Remove("news_ascx");

  • 相关阅读:
    Java多线程同步和异步问题
    最优二叉查找树
    岛屿的周长
    Mac 环境下 go 国内代理配置
    岛屿数量
    字符串解码
    环形链表 II
    颜色分类
    无重复字符的最长子串
    完全平方数
  • 原文地址:https://www.cnblogs.com/mxw09/p/1872972.html
Copyright © 2011-2022 走看看