Session过期跳转问题

思路:在页面初始化的时候判断保存用户信息的Session是否为空,为空则跳转到登陆页面,反之无影响

这边是在webForm的页面初始化的时候进行验证

  override protected void OnInit(EventArgs e)
        {
            if (HttpContext.Current.Session["ACCOUNT_KEY"] == null || HttpContext.Current.Session["ACCOUNT_KEY"].ToString().Equals(""))
            {
                Response.Redirect("~/index.aspx");
            }

            //
            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }

 

在用IFrame的时候有可能跳转不出去,那么在跳转的页面加一个

if (window != top)
top.location.href = location.href;即可

猜你喜欢

转载自www.cnblogs.com/wang-min/p/12403546.html
今日推荐