Esempio n. 1
0
        /// <summary>
        /// 当前的界面的加载前执行的方法。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //判断当前的session中没用用户登录信息,标示用户未登录,直接调转到登录界面。
            if (OperatorProvider.Provider.GetCurrent() == null)
            {
                Response.Write("<script>top.location.href='/WebMaster/Login/Login.aspx'</script>");
                Response.End();
                //Response.Redirect("/WebMaster/Login/Login.aspx"); //对于iframe的页面,不适合使用
            }

            //当前session在全局的session信息是否被强制下线验证,如果已经强制下线,则返回提示信息。
            if (OperatorProvider.CheckIsNoLogin())
            {
                Response.Redirect("/WebMaster/Offline/offline.htm?msg=您的帐号在其他地方已登录,请重新登录!");
            }

            //当用户登录没有问题后,对当前系统的授权情况进行验证,主要是对于机器码以及授权到期验证。
            string licenceMsg = Licence.Target.PageCheckLicence();

            if (licenceMsg != "true")
            {
                string url = "/WebMaster/Error/error.htm?msg=授权验证问题&detail=" + licenceMsg;
                Response.Redirect(WebHelper.UrlEncode(url));
            }

            //LoadHeader();
        }
Esempio n. 2
0
        /// <summary>
        /// 判断用户未登录或者登录被挤掉
        /// </summary>
        /// <param name="nowType">当前请求的处理类类型</param>
        /// <param name="action">当前亲你供求的方法</param>
        /// <param name="response">信息返回对象</param>
        /// <returns></returns>
        private bool CheckUserNoLogin(Type nowType, string action, HttpResponse response)
        {
            CheckLoginAttribute checkLoginAttr = (CheckLoginAttribute)Attribute.GetCustomAttribute(nowType, typeof(CheckLoginAttribute));

            //存在登录验证属性、且类标记为验证状态、且当前请求的方法不再屏蔽验证方法列表中时,进行验证。
            if (checkLoginAttr != null && checkLoginAttr.IsCheck && !checkLoginAttr.IgnoreFunction.Contains(action))
            {
                //判断当前的session中没用用户登录信息,标示用户未登录,直接调转到登录界面。
                if (OperatorProvider.Provider.GetCurrent() == null)
                {
                    RedirectResult(response, "/WebMaster/Login/Login.aspx");
                    return(true);
                }
                //当前session在全局的session信息是否被强制下线验证,如果已经强制下线,则返回提示信息。
                if (OperatorProvider.CheckIsNoLogin())
                {
                    OperatorProvider.Provider.RemoveCurrent();
                    RedirectResult(response, "/WebMaster/Offline/offline.htm?msg=您的帐号在其他地方已登录,请重新登录!");
                    return(true);
                }
            }
            return(false);
        }