62,263
社区成员
发帖
与我相关
我的任务
分享
[/quote]
哈哈,不好意思了,麻烦了两位大神,测试结果出现异常是因为我重写了OnResultExecuting函数,修改了OutputCacheParameters的一个变量造成的,看了system.web.page的源码,发现重写InitOutputCache是可以实现的,但是函数是internal,也不必多此一举,谢谢两位,节日快乐
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom.ToLowerInvariant() == "ismobile" && context.Request.Browser.IsMobileDevice)
{
return "mobile";
}
return base.GetVaryByCustomString(context, custom);
}<%@ OutputCache VaryByCustom="abc" Duration="600000" VaryByParam="none" %>和public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "abc")
{
var key = context.Request.QueryString["key"];
if (key != null)
return key;
}
return base.GetVaryByCustomString(context, custom);
}
那么你可以测试,比如说当你以QueryString参数 key 为什么值(包括不给这个值) 测试时,即使你重启页面,只要是 web 服务没有重启,那么你永远都看到的是过去的那个页面。比如说,在不同页面,查看 http://xxxx/default.aspx 你看到的是30分钟之前的页面,http://xxx/default.aspx?key=1 你看到的是18分钟前的页面,http://xxx/default.aspx?key=2 你看到的是15分钟前的页面,三个页面不论怎么刷新,怎么”切换“,你看到的都是过去的页面。
何来的”就会刷新上次缓存“之说?