有没有办法在webforms中禁用缓存,我不能拥有代码。我有一个webconfig。那是有一种方法来禁用缓存
答案 0 :(得分:3)
将其放入应用beginrequest
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();
答案 1 :(得分:2)
整个项目:
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
或针对特定页面:
Response.Cache.SetCacheability(HttpCacheability.NoCache);