我在包含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"); }
谢谢.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。