3 回答

TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個(gè)贊
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進(jìn)行路由-所以假設(shè)您可以彈出后面的代碼。

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊
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貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個(gè)贊
[System.Web.Mvc.OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]public class NoCacheController : Controller{}
[HttpGet][OutputCache(NoStore = true, Duration = 60, VaryByParam = "*")]public ViewResult Index(){ ...}
添加回答
舉報(bào)