日期:2014-05-17  浏览次数:20400 次

各位大侠请教一下 谁用过 OutputCache 用了更新不了cookie
各位大侠请教一下  谁用过 OutputCache  用了更新不了cookie 

页面设置
<%@ OutputCache Duration="100"  VaryByParam="none" VaryByCustom="UserName"%>

重写
  public override string GetVaryByCustomString(HttpContext context, string arg)
    {
        string key = string.Empty;
        //arg = arg.ToLower();     //outputcache customer   

        //if (arg.Contains("UserName"))          //Login User       
        //{
        //    key += "UserName:" + HttpContext.Current.User.Identity.Name + ";";
        //} 
          //  if (arg.Contains("admin"))        // Is Admin User      
        //{ key += "admin:" + HttpContext.Current.User.Identity.Name + ";-"; }
        //return key;
        if (arg.Contains("UserName"))      //Is UserName List      
        {
            HttpCookie cookie = Request.Cookies["UserName"];
            if (cookie != null)
                return cookie.Value;
        }
        return base.GetVaryByCustomString(context,arg);
    }


但是不管用啊!
检查一下有什么问题么?

------解决方案--------------------
当然不会更新cookie。这个想想就明白了。
------解决方案--------------------
遇到同样的问题,不知道楼主解决了没有,赐教一下
------解决方案--------------------
引用:
怎么才能不缓存cookie,有没有解决方案


不是缓存cookie,而是代码根本就没执行过吧