【发布时间】:2015-04-28 11:19:28
【问题描述】:
我想将我的 MVC 5 应用程序设置为不缓存我的登录视图的页面(即,如果我的用户在浏览器中按下“返回”以导航到登录,我希望登录视图实际重新加载页)。
这样我可以在用户尝试以其他人身份登录之前将当前用户注销。
我在 Global.asax 中看到有人使用它的例子:
protected void Application_BeginRequest()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetNoStore();
Response.Cache.SetProxyMaxAge(new TimeSpan(0, 0, 0));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
}
但这会停止缓存每个请求的每个页面。 我相信有办法通过路由或过滤器来做到这一点?也许是方法注释?谁能解释一下?
【问题讨论】:
标签: c# asp.net asp.net-mvc caching httpcontext