Asp.Net浏览器缓存、信息安全问题
2013-07-05 15:06
267 查看
废话不多说直接上代码!
第一、禁止登陆页面在浏览器端缓存
<%
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
Response.Expires = -1;
Response.AddHeader("pragma", "no-cache");
Response.AddHeader("pragma", "no-store");
Response.CacheControl = "no-cache";
%>
第二、服务器端做用户权限安全校验
protected void Page_Load(object sender, EventArgs e)
{
if (Common.SessionManage.login)
{
Common.SessionManage.RemoveAll_Session();
}
}
第三、安全跳转,所有需要权限校验的页面都继承BasePage
public class LoginPage:BasePage
{
protected override void OnPreLoad(EventArgs e)
{
if (!Common.SessionManage.login)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script type=\"text/javascript\">");
sb.Append("if ((window.top!=null) && (window.top.opener!=null)){alert('操作超时,请重新登录!');window.top.opener.location.href = \"/login.aspx\";window.top.close();}");
sb.Append("else{if ((window.top!=null) && (window.top.location.href!=window.location.href)) {alert('操作超时,请重新登录!');window.top.location.href = \"/login.aspx\";} else{ alert('操作超时,请重新登录!'); window.location.href = \"/login.aspx\";}}");
sb.Append("</script>");
Response.Write(sb.ToString());
Response.End();
}
base.OnPreLoad(e);
}
}
第一、禁止登陆页面在浏览器端缓存
<%
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
Response.Expires = -1;
Response.AddHeader("pragma", "no-cache");
Response.AddHeader("pragma", "no-store");
Response.CacheControl = "no-cache";
%>
第二、服务器端做用户权限安全校验
protected void Page_Load(object sender, EventArgs e)
{
if (Common.SessionManage.login)
{
Common.SessionManage.RemoveAll_Session();
}
}
第三、安全跳转,所有需要权限校验的页面都继承BasePage
public class LoginPage:BasePage
{
protected override void OnPreLoad(EventArgs e)
{
if (!Common.SessionManage.login)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script type=\"text/javascript\">");
sb.Append("if ((window.top!=null) && (window.top.opener!=null)){alert('操作超时,请重新登录!');window.top.opener.location.href = \"/login.aspx\";window.top.close();}");
sb.Append("else{if ((window.top!=null) && (window.top.location.href!=window.location.href)) {alert('操作超时,请重新登录!');window.top.location.href = \"/login.aspx\";} else{ alert('操作超时,请重新登录!'); window.location.href = \"/login.aspx\";}}");
sb.Append("</script>");
Response.Write(sb.ToString());
Response.End();
}
base.OnPreLoad(e);
}
}
相关文章推荐
- ASP.NET MVC中使用jQuery时的浏览器缓存问题详解
- ASP.NET MVC中使用jQuery时的浏览器缓存问题
- 大叔手记(20):ASP.NET MVC中使用jQuery时的浏览器缓存问题
- ASP.NET MVC中使用jQuery时的浏览器缓存问题
- Asp.net获取客户浏览器信息,Chrome名称不匹配问题
- ASP.NET MVC中使用jQuery时的浏览器缓存问题详解
- ASP.NET MVC中使用jQuery时的浏览器缓存问题
- ASP.NET安全问题--ASP.NET安全架构--如何实现.NET安
- asp.net 取消缓存相关问题说明
- asp.net退出登陆(解决退出后点击浏览器后退问题仍然可回到页面问题)
- ASP.NET母版缓存问题
- ASP.NET开发实践系列课程之Web应用的安全攻防之垃圾信息群发(SPAM)
- asp.net 取消缓存相关问题
- 细说 ASP.NET控制HTTP缓存--浏览器缓存
- 解決 IE10 浏览器无法使用 ASP.NET 表单验证登录的问题
- .Html+Asp+asp.net(C#)禁止浏览器缓存页面的方法-禁止缓存
- ASP.NET安全问题--ASP.NET安全架构
- ASP.NET获取客户端的操作系统、浏览器、.NET版本等信息(图)
- ASP.NET MVC 3:缓存功能的设计问题
- ASP.NET MVC 3:缓存功能的设计问题