5
我已經創建了我的自定義驗證。現在我想在註銷按鈕單擊時禁用緩存。我應該怎麼做?我應該在註銷操作中包含哪些內容?如何在asp.net mvc 3中禁用瀏覽器緩存?
我在下面:http://www.bradygaster.com/custom-authentication-with-mvc-3.0
我已經創建了我的自定義驗證。現在我想在註銷按鈕單擊時禁用緩存。我應該怎麼做?我應該在註銷操作中包含哪些內容?如何在asp.net mvc 3中禁用瀏覽器緩存?
我在下面:http://www.bradygaster.com/custom-authentication-with-mvc-3.0
是您的關心瀏覽器的後退按鈕註銷後?
如果是,那麼在註銷時不應禁用緩存。你應該在你不希望被緩存的所有頁面上禁用它,在你的情況下這將是所有的認證頁面。
public class NoCacheAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var response = filterContext.HttpContext.Response;
response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
response.Cache.SetValidUntilExpires(false);
response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
response.Cache.SetCacheability(HttpCacheability.NoCache);
response.Cache.SetNoStore();
}
}
,然後用它裝飾你的行動:
[Authorize]
[NoCache]
public ActionResult Foo()
{
...
}
你只需要刪除會話cookie – 2012-07-20 06:16:11
我可以刪除會話cookie
這可以通過編寫自定義動作過濾器來完成但我怎麼能禁用browswer緩存/刪除緩存歷史按下注銷按鈕 – kiransh 2012-07-20 06:39:51