2010-05-29 88 views
0

我想禁用不使用JavaScript的broswer後退按鈕。到目前爲止,我已經使用這個代碼:禁用沒有JavaScript的後退按鈕(顯示緩存版本)

Response.CacheControl = "no-cache" 
Response.CacheControl = "private" 
Response.CacheControl = "public" 

它在Internet Explorer 8中,但在Mozilla火狐狸它不是的情況下工作正常working.pls說同樣的解決方案,在所有的瀏覽器。

在此先感謝

與問候 V.karthik

+0

我正在更正標題,所以這不會得到不必要的迴應票,因爲您之後的無緩存完全有效......只是「禁用後退按鈕」因爲很好的理由,我會發現自己會皺起眉頭:)但這與你在這裏之後的不同。 – 2010-05-29 14:16:33

回答

0

嘗試

Response.Cache.SetCacheability(HttpCacheability.NoCache) 
0

退房在這個問題的回答:

Best way to disable client caching

這是同樣的問題,同樣的公關會議(IE工作,FF不)和一個可接受的解決方案。我引用:

Expires: Sun, 19 Nov 1978 05:00:00 GMT 
Last-Modified: Fri, 12 Jun 2009 08:01:46 GMT (the actual modification date) 
Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0 

編輯:

您可以在頁面的代碼隱藏設置的前兩個標題是這樣的:

this.Response.Cache.SetExpires(DateTime.Now); 
this.Response.Cache.SetLastModified(DateTime.Now); 

但實際上,它應該是足夠的做以下來禁用緩存(另請參閱Whats the best way to deal with pages loaded via browser history in asp .net?):

this.Response.Cache.SetCacheability(HttpCacheability.NoCache); 
this.Response.Cache.SetNoStore(); 

這會生成以下標題:

Cache-Control: no-cache, no-store 
Pragma: no-cache 
Expires: -1 
+0

在哪裏使用此編碼詳細我 – 2010-05-31 05:32:17

+0

如何使用這些編碼和在哪裏使用 – 2010-05-31 10:03:40

+0

我添加了其他鏈接和一些代碼。 – marapet 2010-05-31 11:42:13