首先定义一个过滤器
public class NoCacheAttribute : ActionFilterAttribute{public override void OnResultExecuting(ResultExecutingContext filterContext){filterContext.HttpContext.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);filterContext.HttpContext.Response.Cache.SetNoStore();}}
然后注册到全局过滤器
public static void RegisterGlobalFilters(GlobalFilterCollection filters){filters.Add(new HandleErrorAttribute());filters.Add(new NoCacheAttribute());}
如果觉得《Asp.Net MVC 禁止页面缓存》对你有帮助,请点赞、收藏,并留下你的观点哦!