如何不允许用户使用浏览器的『后退按钮』查看前面缓存下来的页面。

本人正在使用C#开发中国电信一项目。现在遇到一个问题一直无法解决,请各位高手指点

就是在Web页面中,按退出登录按钮以后,不允许用户使用浏览器的『后退按钮』查看前面缓存下来的页面。可以用两种方式:一是不允许回退,二是如果回退,则提示页面过期。请问有没有什么好的实现方法?

多谢了、
---------------------------------------------------------------

告诉你一个简单的办法,写一个页面基类:

public class PageBase : Page
{
public PageBase() {}

protected override OnLoad( EventArgs e ) {
Response.Cache.SetNoStore();
base.OnLoad();
}
}

然后把所有的页面从这个页面继承,查找替换就行了

或者在Global里面:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext.Current.Response.Cache.SetNoStore();
}

Published At
Categories with Web编程
Tagged with
comments powered by Disqus