public override void OnException(MethodExecutionArgs args) { MethodInfo methodInfo = args.Method as MethodInfo; if (methodInfo != null) { Type returnType = methodInfo.ReturnType; if (returnType == typeof(int)) { args.FlowBehavior = FlowBehavior.Return; args.ReturnValue = -1; } else if (returnType == typeof(bool)) { args.FlowBehavior = FlowBehavior.Return; args.ReturnValue = false; } else if (returnType == typeof(ActionResult)) { args.FlowBehavior = FlowBehavior.Return; if (MySession.Get("LoginUser") != null) { args.ReturnValue = new RedirectToRouteResult( new RouteValueDictionary { { "action", "Index" }, { "controller", "Home" } }); } else { args.ReturnValue = new RedirectToRouteResult( new RouteValueDictionary { { "action", "Index" }, { "controller", "Login" } }); } } else if (returnType.IsClass) { args.FlowBehavior = FlowBehavior.Return; args.ReturnValue = null; } } if (HttpContext.Current != null) { Helpers.Logger.Instance.LogException(args.Exception); } else { throw args.Exception; } base.OnException(args); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (MySession.Get("LoginUser") == null) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Login" }, { "action", "Index" } }); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (MySession.Get("LoginUser") == null || ((LoginUser)MySession.Get("LoginUser")).UserTypeId != (int)UserType.Admin) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Home" }, { "action", "Index" } }); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (MySession.Get("LoginUser") != null && filterContext.ActionDescriptor.ActionName != "Logoff") { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Home" }, { "action", "Index" } }); } }
public UserController() { _postsRepo = DalFactory.GetPostsRepo(); _usersDal = DalFactory.GetUsersRepo(); _loginUser = (LoginUser)MySession.Get("LoginUser"); }
public PostController() { _postsRepo = DalFactory.GetPostsRepo(); _loginUser = (LoginUser)MySession.Get("LoginUser"); _fileSystem = new FileSystem(); }
public SettingsController() { userDAL = DalFactory.GetUsersRepo(); LoginUser = (LoginUser)MySession.Get("LoginUser"); }