Asp.net 不使用JavaScript禁用后退按钮(显示缓存版本)

Asp.net 不使用JavaScript禁用后退按钮(显示缓存版本),asp.net,Asp.net,我想在不使用javascript的情况下禁用broswer back按钮。到目前为止,我使用了以下编码: Response.CacheControl = "no-cache" Response.CacheControl = "private" Response.CacheControl = "public" 它在InternetExplorer8中运行良好,但在mozilla fire fox中不起作用。请说同样的解决方案适用于所有浏览器 提前谢谢 关于 V.karthik试试看 Respon

我想在不使用javascript的情况下禁用broswer back按钮。到目前为止,我使用了以下编码:

Response.CacheControl = "no-cache"
Response.CacheControl = "private"
Response.CacheControl = "public"
它在InternetExplorer8中运行良好,但在mozilla fire fox中不起作用。请说同样的解决方案适用于所有浏览器

提前谢谢

关于 V.karthik试试看

Response.Cache.SetCacheability(HttpCacheability.NoCache)

查看此问题的回答:

这是同一个问题,同一个问题。我引用:

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
编辑:

您可以在页面的codebehind中设置前两个标题,如下所示:

this.Response.Cache.SetExpires(DateTime.Now);
this.Response.Cache.SetLastModified(DateTime.Now);
但实际上,要停用缓存,只需执行以下操作即可。另请参见:

这将生成以下标题:

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

我正在更正标题,这样就不会得到不必要的否决票,因为你所追求的无缓存是完全有效的…只是禁用你会发现的后退按钮是不受欢迎的,有充分的理由:但这与你在这里所追求的不同。在哪里使用这种编码和我一样详细。如何使用这些编码和在哪里使用它不适用于mozila firefox3.6.3和safari 4.0。请帮助我在所有浏览器中工作。并说明编码在哪里使用。我很挣扎。但它在ie和google chrome中运行良好。你可以例如,在页面加载事件处理程序中使用它。请注意,回发后,您应该重定向到其他页面。另请参见,我在页面加载事件中使用了此编码,它仅在ie HttpContext.Current.Response.Cache.SetExpiresDateTime.UtcNow.AddDays-1 HttpContext.Current.Response.Cache.SetValidUntileExpiresFalse HttpContext.Current.Response.Cache.SetRevalidationHttpCacheRevalidation.AllCaches中起作用HttpContext.Current.Response.Cache.SetCacheabilityHttpCacheability.NoCache HttpContext.Current.Response.Cache.SetNoStore(如果mozilla不工作)
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: -1