过滤asp.net页面每次发出请求之前访问
2015-05-27 11:06
246 查看
public class PageFiltert : System.Web.UI.Page
{
public PageFiltert()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
protected override void OnPreInit(EventArgs e)
{
//context.PostRequestHandlerExecute += new EventHandler(this.Application_beginRequest);
//this.OnPreInit += new System.EventHandler(Application_beginRequest);
//this.Load += new System.EventHandler(Application_beginRequest);
if (!Page.IsPostBack)
{
if (HttpContext.Current.Session["userName"] == null)
{
HttpContext.Current.Response.Write("<script>window.parent.location.href='../../login.aspx'</script>");//必须是根目录
Response.End();
//HttpContext.Current.Response.Redirect("~/login.aspx");
}
}
base.OnPreInit(e);
}
}
{
public PageFiltert()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
protected override void OnPreInit(EventArgs e)
{
//context.PostRequestHandlerExecute += new EventHandler(this.Application_beginRequest);
//this.OnPreInit += new System.EventHandler(Application_beginRequest);
//this.Load += new System.EventHandler(Application_beginRequest);
if (!Page.IsPostBack)
{
if (HttpContext.Current.Session["userName"] == null)
{
HttpContext.Current.Response.Write("<script>window.parent.location.href='../../login.aspx'</script>");//必须是根目录
Response.End();
//HttpContext.Current.Response.Redirect("~/login.aspx");
}
}
base.OnPreInit(e);
}
}
相关文章推荐
- c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求
- c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求
- c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求
- [转] c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求
- asp.net-由于权限不足而无法读取配置文件,无法访问请求的页面
- 转 c# 模拟Asp.net页面中的某个按钮的点击,向web服务器发出请求
- 每次我们请求一个asp.net页面时,我们都经历着同样的过程
- ASP.NET页面请求流程
- 解决ASP.NET中Redis 每小时6000次访问请求的问题
- asp.net如何让未登录用户登录后能自动跳转到登录前访问的页面
- asp.net富文本提交(不使用2.0请求方式,不禁用页面检查)
- 从另外角度-解决ASP.NET每一个页面首次访问慢的问题
- Asp.net自动返回上次请求页面
- asp.net页面过滤所有换行符和多余空格
- asp.net 访问页面访问统计实现
- Asp.Net请求原理and页面生命周期
- IIS7 ASP.NET 未被授权访问所请求的资源
- ASP.NET中每个页面在Load之前调用公用函数
- 访问ASP.NET页面时候出现权限问题的解决
- ASP.NET查询页面设置form的action属性只弹出一个页面,并且每次将页面设置到最前