public JsonResult GetSessionUser()
        {
            var user = Session["CurrentUser"] as CurrentUser;

            if (user != null)
            {
                user.Sys_User.Themes = EasyuiThemesHelper.GetValue(user.Sys_User.Uid);
            }
            return(Json(user.Sys_User));
        }
Esempio n. 2
0
        /// <summary>
        /// 被拦截Action前执行
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // base.OnActionExecuting(filterContext);
            var sessionUser = filterContext.HttpContext.Session["CurrentUser"];

            if (sessionUser == null)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                {
                    controller = "Account",
                    action     = "Login"
                }));
                return;
                //filterContext.Result = new ContentResult() { Content = "登录超时,请重新登录" };
                //filterContext.Result = new JavaScriptResult() { Script = "alert('dfd')" };
                //var result= new JavaScriptResult() { Script = "window.top.location.href = '/Account/Login'" };
            }
            var user = sessionUser as CurrentUser;

            filterContext.Controller.ViewData["easyuiTheme"] = EasyuiThemesHelper.GetValue(user.Sys_User.Uid);
            base.OnActionExecuting(filterContext);
        }