0

如何使用系统缓存对象HttpContext.Current.Cache将自定义服务器控件存储在缓存中?如何缓存复合服务器控件?

目前,我有代码看起来像这样:

  string adxkey = string.Format("adxdependency:document:{0}", this.SearchRootDocumentKey); 
     System.Web.Caching.CacheDependency cd = new System.Web.Caching.CacheDependency(null, new string[] { adxkey }); 
     HttpContext.Current.Cache.Insert(adxkey, this, cd); 

这是位于诠释,他的OnInit方法。我的问题是:

  • 有没有更好的方法来放置缓存代码?
  • 您是否可以通过像上面那样传递对它的引用来缓存服务器控件?或者我需要缓存呈现的HTML?

如何以编程方式缓存服务器控件的示例将不胜感激!谢谢。

回答