结果。。。
protected override void OnActionExecuted(ActionExecutedContext filterContext) { //Add the ActionResult to cache List<BlogsClass> list; if (filterContext.HttpContext.Cache["filterContext"] == null) { IClass _Class = new CalssData(); list = _Class.GetParentClass(0); filterContext.HttpContext.Cache.Add("Class", list, null, DateTime.Now.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, null); } else { list = filterContext.HttpContext.Cache["filterContext"] as List<BlogsClass>; } //Add a value in order to know the last time it was cached. //filterContext.Controller.ViewData["CachedStamp"] = DateTime.Now; ViewBag["Class"] = list; base.OnActionExecuted(filterContext); }
参考:http://www.codeproject.com/Articles/33431/ASP-NET-MVC-Result-Cache
转载于:https://www.cnblogs.com/wugang/p/3175097.html