コード例 #1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if (!filterContext.HttpContext.Request.IsAjaxRequest())
            {
                CurrentDb.SysPageAccessRecord.Add(new SysPageAccessRecord()
                {
                    UserId = User.Identity.GetUserId <int>(), AccessTime = DateTime.Now, PageUrl = filterContext.HttpContext.Request.Url.AbsolutePath, Ip = CommonUtils.GetIP()
                });
                CurrentDb.SaveChanges();
            }

            ILog log = LogManager.GetLogger(CommonSetting.LoggerAccessWeb);

            log.Info(FormatUtils.AccessWeb(User.Identity.GetUserId <int>(), User.Identity.GetUserName()));

            bool skipAuthorization = filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), inherit: true) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), inherit: true);

            if (!skipAuthorization)
            {
                if (filterContext.HttpContext.Request.Url.AbsolutePath.IndexOf(WebBackConfig.GetLoginPage()) == -1)
                {
                    if (Request.IsAuthenticated)
                    {
                        var userId = User.Identity.GetUserId <int>();
                        var user   = CurrentDb.SysStaffUser.Where(m => m.Id == userId).FirstOrDefault();
                        if (user == null)
                        {
                            Response.Redirect(WebBackConfig.GetLoginPage() + "?out=0");
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            SetTrackID();

            ILog log = LogManager.GetLogger(CommonSetting.LoggerAccessWeb);

            log.Info(FormatUtils.AccessWeb(this.CurrentUserId, ""));
        }
コード例 #3
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            CurrentDb.SysPageAccessRecord.Add(new SysPageAccessRecord()
            {
                UserId = User.Identity.GetUserId <int>(), AccessTime = DateTime.Now, PageUrl = filterContext.HttpContext.Request.Url.AbsolutePath, Ip = CommonUtils.GetIP()
            });
            CurrentDb.SaveChanges();

            ILog log = LogManager.GetLogger(CommonSetting.LoggerAccessWeb);

            log.Info(FormatUtils.AccessWeb(User.Identity.GetUserId <int>(), User.Identity.GetUserName()));
        }