读书人

各位大侠请问一下 哪位高手用过 Outp

发布时间: 2014-05-11 16:09:53 作者: rapoo

各位大侠请教一下 谁用过 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,而是代码根本就没执行过吧

读书人网 >asp.net

热点推荐