开发者

Disable Back Button (showing cached version) without JavaScript

开发者 https://www.devze.com 2023-01-01 18:08 出处:网络
I want to disable the broswer back button without using javascript.So far i have used this 开发者_运维百科coding:

I want to disable the broswer back button without using javascript. So far i have used this 开发者_运维百科coding:

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

It's working fine in the internet explorer 8 but in case of mozilla fire fox it is not working.pls say same the solution to work in all browsers.

Thanks in advance

With Regards V.karthik


Try

Response.Cache.SetCacheability(HttpCacheability.NoCache)


Check out the response in this question:

Best way to disable client caching

It's the same question, the same problem (IE working, FF not), and an accepted solution. I'm quoting:

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

EDIT:

You can set the first two header like this in the codebehind of your page:

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

But actually, it should be enough to do the following to deactivate caching (see also 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();

This generates the following headers:

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

精彩评论

暂无评论...
验证码 换一张
取 消