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); }
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"); } }