3 回答
TA贡献1826条经验 获得超6个赞
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();
所有请求都会首先通过default.aspx进行路由-所以假设您可以弹出后面的代码。
TA贡献1818条经验 获得超3个赞
public class NoCacheAttribute : ActionFilterAttribute{ public override void OnResultExecuting(ResultExecutingContext filterContext) { filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false); filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); filterContext.HttpContext.Response.Cache.SetNoStore(); base.OnResultExecuting(filterContext); }}
[NoCache][HandleError]public class AccountController : Controller{ [NoCache] [Authorize] public ActionResult ChangePassword() { return View(); }}
TA贡献1794条经验 获得超8个赞
[System.Web.Mvc.OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]public class NoCacheController : Controller{}
[HttpGet][OutputCache(NoStore = true, Duration = 60, VaryByParam = "*")]public ViewResult Index(){ ...}
添加回答
举报