2014/9/17

Question:
在登入頁面成功登入後建立Session並轉址到其他網頁,
但使用瀏覽器「上一頁」動作後,
因瀏覽器快取網站資訊,所以原先建立的Session資料也讀不到了...

Solve:
專案使用的是C#/MVC,
在MVC的Controller裡引入以下code:

protected override void Initialize(RequestContext requestContext)
{
    base.Initialize(requestContext);
    requestContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    requestContext.HttpContext.Response.Cache.SetExpires(DateTime.MinValue);
    requestContext.HttpContext.Response.Cache.SetNoStore();
}

立馬停止瀏覽器快取網站!
建立的Session在瀏覽器「上一頁」動作後也不會消失~

17 Sep 2014
Next
較新的文章
Previous
This is the last post.

0 意見:

張貼留言

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.