c# – Asp.Net OutputCache和Expiration
发布时间:2020-12-15 17:15:33 所属栏目:百科 来源:网络整理
导读:我在包含usercontrol的页面上使用 Asp.net OutputCache,在某些情况下,当编辑usercontrol时,我希望能够使页面缓存过期并使用新数据重新加载页面. 有什么方法可以在usercontrol中做到这一点吗? 如果没有,那么缓存页面的其他一些方法将允许我以这种方式进行编
我在包含usercontrol的页面上使用
Asp.net OutputCache,在某些情况下,当编辑usercontrol时,我希望能够使页面缓存过期并使用新数据重新加载页面.
有什么方法可以在usercontrol中做到这一点吗? 如果没有,那么缓存页面的其他一些方法将允许我以这种方式进行编辑. ———–编辑———– 经过一些研究后,我发现了一种似乎运作良好的方法. Dim cachekey As String = String.Format("Calendar-{0}",calendarID) HttpContext.Current.Cache.Insert(cachekey,DateTime.Now,Nothing,System.DateTime.MaxValue,System.TimeSpan.Zero,System.Web.Caching.CacheItemPriority.NotRemovable,Nothing) Response.AddCacheItemDependency(cachekey) 这将添加一个依赖页面缓存对象,然后到期我这样做: Dim cachekey as string = String.Format("Calendar-{0}",CalendarID) HttpContext.Current.Cache.Insert(cachekey,Nothing) 现在,只要知道依赖关系缓存密钥,页面就可以过期. 解决方法
你可以试试这个:
private void RemoveButton_Click(object sender,System.EventArgs e) { HttpResponse.RemoveOutputCacheItem("/caching/CacheForever.aspx"); } 来自:http://aspalliance.com/668 谢谢. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |