예제 #1
0
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var user = UserTicketHelper.GetUserFromCookie(filterContext.HttpContext.Request.Cookies["user"]);

            if (user != null)
            {
                filterContext.Controller.ViewData["userInfo"] = user;
            }

            base.OnResultExecuting(filterContext);
        }
예제 #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var userCookie = filterContext.HttpContext.Request.Cookies["user"];
            var user       = UserTicketHelper.GetUserFromCookie(userCookie);

            if (user != null)
            {
                filterContext.Controller.ViewData["userInfo"] = user;
                base.OnActionExecuting(filterContext);
            }
            else
            {
                filterContext.Result = new RedirectResult("/Account/Login");
            }
        }