0

我使用以下文章创建了一个关于在 asp.net mvc2 应用程序中显示会话过期警告消息的 POC。 http://www.fairwaytech.com/2012/01/handling-session-timeout-gracefully/

我对代码进行了一项更改,如下所述:

location.href = expireSessionUrl;在endSession方法中改成如下代码:

window.location.replace(expireSessionUrl);

一旦用户单击会话警告消息对话框中的注销按钮,他就会导航到注销视图。但是在这里,如果他单击浏览器后退按钮,他将被导航到上一页。

如前所述,我有以下修改的过期方法:

[Authorize]
public virtual ActionResult Expire()
{
Session.Clear();
FormsService.SignOut();
HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Response.Cache.SetValidUntilExpires(false);
HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Response.Cache.SetNoStore();
return Redirect(“/”);
}

你能指导我解决这个问题吗?

在此先感谢 Santosh Kumar Patro

4

1 回答 1

0

你需要让你的缓存过期,试试这个:

Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)

或来自文档

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);

或者您可以使用Response.CacheControl来控制页面在用户缓存中的存储方式

于 2013-04-13T13:35:28.127 回答