简体   繁体   English

在Safari中使用浏览器后退按钮时,从浏览器缓存中重新加载了Asp.net MVC视图/页面

[英]Asp.net mvc view/page reloaded from browse cache when using browser back button in Safari

I have Asp.net MVC page/view is always fetched from cache when using browser back button. 使用浏览器后退按钮时,我总是从缓存中获取Asp.net MVC页面/视图。 This issue is with safari browser alone and works properly in other browser such as Chrome,Firefox and IE. 这个问题仅与Safari浏览器有关,并且可以在其他浏览器(例如Chrome,Firefox和IE)中正常运行。 I went through so many posts which describes similar issues. 我浏览了很多描述类似问题的帖子。 But till now I am not able find a solution for this . 但是到目前为止,我还无法找到解决方案。

This is below code from my action method 这是我的动作方法下面的代码

[OutputCache(Duration = 0, Location = OutputCacheLocation.Any, VaryByParam = "*")]
 public ActionResult ABC(string taxonomy)
 {
    return View()
 }

In safari response shows the below 在野生动物园中的响应显示以下内容

Cache-Control:public, max-age=0, s-maxage=0
Connection:Close
Content-Length:15849
Content-Type:text/html; charset=utf-8
Date:Wed, 12 Nov 2014 06:07:55 GMT
Expires:Wed, 12 Nov 2014 06:07:52 GMT
Last-Modified:Wed, 12 Nov 2014 06:07:52 GMT
Server:ASP.NET Development Server/10.0.0.0
Vary:*
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:4.0

I have also tried added the bleow code to the action method 我也尝试过将bleow代码添加到action方法中

[OutputCache(Duration = 0, Location = OutputCacheLocation.Any, VaryByParam = "*")]
public ActionResult ABC(string taxonomy)
{
HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Response.AppendHeader("Cache-Control", "private, no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0"); // HTTP 1.1.
HttpContext.Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
HttpContext.Response.AppendHeader("Expires", "0"); // Proxies.
HttpContext.Response.AppendHeader("Vary", "*");
}

So the response was like below 所以响应如下

Cache-Control:no-cache
Connection:Close
Content-Length:15849
Content-Type:text/html; charset=utf-8
Date:Wed, 12 Nov 2014 06:20:58 GMT
Expires:-1
Pragma:no-cache, no-cache
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:4.0

But what ever i do the the safari get's the page from cache when i use the back button of the browser. 但是,当我使用浏览器的后退按钮时,我从野生动物园获取野生动物园的页面的方法是什么。 Kindly help with solution /suggestion to solve this problem . 请提供解决方案/建议来解决此问题。

I had similar problem with Safari and adding onunload="" in body tag and I solved it. 我在Safari中遇到了类似的问题,并在body标签中添加了onunload="" ,我解决了它。 Check: Preventing cache on back-button in Safari 5 检查: 在Safari 5中防止在后退按钮上缓存

I found this alternative approach which solved my problem . 我找到了解决问题的替代方法。 Hope this help everyone facing similar issues How do you disable back and forward caching on iOS Safari? 希望这对遇到类似问题的所有人有所帮助。 如何在iOS Safari上禁用前进和后退缓存?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用浏览器后退按钮从另一个页面返回时,ASP.NET Gridview分页不保留 - ASP.NET Gridview paging not retaining when we come back from another page using browser back button 在SignOut()之后使用浏览器的后退按钮允许访问安全页面(ASP.NET MVC) - Using the browser's back button after SignOut() allows access to secure page (ASP.NET MVC) ASP.NET MVC 2在部分视图中禁用浏览器后退按钮的缓存 - ASP.NET MVC 2 disable cache for browser back button in partial views 无法浏览asp.net mvc 4页面 - unable to browse asp.net mvc 4 page 阻止浏览器后退按钮重定向到asp.net mvc2中的上一页 - Prevent browser back button to redirect to the previous page in asp.net mvc2 通过浏览器后退按钮转到后退页面时,Asp.Net标签文本将重置 - Asp.Net label text resets when go to back page through browser back button 当用户单击未设置缓存的返回按钮时,防止 ASP.NET Webforms 中的页面过期消息 - Prevent page expired message in ASP.NET Webforms when user click back button with no-cache set 使用浏览器后退按钮加载ASP.NET页面 - ASP.NET Page loading with browser back button ASP.NET/jQuery后退,但使用浏览器的“后退”按钮时不这样做 - ASP.NET/jQuery Post-Back, but not when using browser's “Back” button 单击浏览器上的“后退”按钮时的Asp.Net Force Page_Load - Asp.Net Force Page_Load when Clicking Back Button On Browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM