我有代码可以在我的 MVC 应用程序中禁用缓存。我正在使用以下响应 header 。它们似乎适用于除 Chrome 之外的所有浏览器(当前使用版本 31.0.1650.48)。用户可以提交包含模型值的表单。当他们点击后退按钮时,我需要使用空白模型重新加载页面。由于请求正在执行操作并返回空白模型,因此 header 似乎部分有效。但是 View 没有更新。上一篇文章中的值将被保留。我尝试清除 ModelState 但这不起作用。有什么建议么?提前致谢!!
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(False)
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache)
filterContext.HttpContext.Response.Cache.SetNoStore()
最佳答案
关闭表单的自动完成功能为我解决了这个问题。我感谢所有的意见!
<form autocomplete="off"></form>
关于asp.net-mvc - ASP.NET MVC 4.0 Chrome 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19981991/