Ejemplo n.º 1
0
        /// <summary>
        /// Action执行前
        /// </summary>
        /// <param name="filterContext">上下文</param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                // var isajax = HttpContext.Current.Request.Headers["x-requested-with"];

                object[] actionFilter     = filterContext.ActionDescriptor.GetCustomAttributes(typeof(NoCompress), false);
                object[] controllerFilter = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(NoCompress), false);
                if (controllerFilter.Length == 1 || actionFilter.Length == 1)
                {
                    return;
                }
                bool flag = AES.UrlEncrypt(CookieHelp.GetCookieValByKey("Userid") + CookieHelp.GetCookieValByKey("LoginName")) == AES.UrlEncrypt(CookieHelp.GetCookieValByKey("long"));
                if (string.IsNullOrEmpty(CookieHelp.GetCookieValByKey("Userid")) || !flag)
                {
                    HttpContext.Current.Response.Clear();
                    filterContext.Result = new RedirectResult(AppConfig.LoginUrl);
                    HttpContext.Current.Response.Write("<script>parent.parent.window.location='" + AppConfig.LoginUrl + "';parent.window.location='" + AppConfig.LoginUrl + "'</script>");
                    HttpContext.Current.Response.End();
                    filterContext.Result = new EmptyResult();
                }
                base.OnActionExecuting(filterContext);
            }
            catch (Exception exception)
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(exception.Message);
                HttpContext.Current.Response.End();
                filterContext.Result = new EmptyResult();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="Pwd"></param>
        /// <returns></returns>
        public ActionResult UpdatePwd(string Pwd)
        {
            user u = new user();

            u.Id   = Convert.ToInt64(CookieHelp.GetCookieValByKey("UserId"));
            u.Pwd  = Pwd;
            fileds = new[]  { "Pwd" };
            return(base.Update(u));
        }
Ejemplo n.º 3
0
        public static bool isHasQuanXian(string action)
        {
            string UserId = CookieHelp.GetCookieValByKey("UserId");

            Func <List <string> > per         = () => new List <string>();
            List <string>         btnquanxian = CacheHelper.GetCache(UserId, per);

            if (btnquanxian.Contains(action))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }