Exemple #1
0
        public ResultModel CheckLogin(string accName, string passWord)
        {
            //登录事件中,写Cookie ,调用wcf的Login方法来写Cache
            UserService userService = new UserService();
            ResultModel result = userService.Login(accName, passWord);

            if (result.ResultStatus == 0)
            {
                HttpCookie tokenCookie = new HttpCookie(DefaultValue.CookieName, result.ReturnValue.ToString())
                {
                    Domain = DefaultValue.Domain,
                    Path = "/",
                    //Expires = DateTime.Now.AddMinutes(DefaultValue.CacheExpiration)
                };
                Response.Cookies.Add(tokenCookie);
            }

            return result;
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //清除Cookie 并调用wcf LoginOut方法以达到清除Cache效果
            HttpCookie cookie = Request.Cookies[DefaultValue.CookieName];
            if (cookie != null)
            {
                string token = cookie.Value;
                UserService userService = new UserService();
                userService.LoginOut(token);

                cookie.Domain = NFMT.Common.DefaultValue.Domain;
                cookie.Expires = DateTime.Now.AddDays(-1);
                Request.Cookies.Add(cookie);
                cookie.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(Request.Cookies[DefaultValue.CookieName]);
            }

            //页面跳转
            //string redirectUrl = Request.QueryString["redirectUrl"];
            //if (string.IsNullOrEmpty(redirectUrl))
            string redirectUrl = string.Format("{0}login.aspx",NFMT.Common.DefaultValue.NfmtPassPort);
            Response.Redirect(redirectUrl);
        }