示例#1
0
        /// <summary>
        /// 从Cookie中读取认证信息
        /// </summary>
        /// <returns></returns>
        public static ISignInInfo LoadFromCookie()
        {
            SignInInfo signInInfo = null;

            Common.CheckHttpContext();

            HttpRequest request = HttpContext.Current.Request;

            HttpCookie cookie = request.Cookies[GetLoadingCookieKey()];

            if (cookie != null)
            {
                string strSignIn = cookie.Value;

                try
                {
                    signInInfo = new SignInInfo(Common.DecryptString(strSignIn));
                }
                catch (System.Exception)
                {
                    //如果cookie的格式错误,不予理睬
                }
            }

            return signInInfo;
        }
示例#2
0
        /// <summary>
        /// 从Cookie中读取认证信息
        /// </summary>
        /// <returns></returns>
        public static ISignInInfo LoadFromCookie()
        {
            SignInInfo signInInfo = null;

            Common.CheckHttpContext();

            HttpRequest request = HttpContext.Current.Request;

            HttpCookie cookie = request.Cookies[GetLoadingCookieKey()];

            if (cookie != null)
            {
                string strSignIn = cookie.Value;

                try
                {
                    signInInfo = new SignInInfo(Common.DecryptString(strSignIn));
                }
                catch (System.Exception)
                {
                    //如果cookie的格式错误,不予理睬
                }
            }

            return(signInInfo);
        }
示例#3
0
        /// <summary>
        /// 清除认证服务的Cookie
        /// </summary>
        public static void ClearSignInCookie()
        {
            Common.CheckHttpContext();

            HttpContext  context  = HttpContext.Current;
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            HttpCookie cookie = request.Cookies[SignInInfo.GetLoadingCookieKey()];

            if (cookie != null)
            {
                cookie.Expires = SNTPClient.AdjustedTime.AddDays(-1);

                cookie.Value = null;
                response.SetCookie(cookie);
            }
        }