///this is necessary for the layout service since the actionFilter does not capture razorpages
        ///not sure why it breaks if I disable post request but it does, so I don't
        ///you can not even check for model state valid, because it will still render if the login info is not valid
        public void OnPageHandlerExecuting(PageHandlerExecutingContext context)
        {
            var req  = context.HttpContext.Request;
            var resp = context.HttpContext.Response;
            var user = context.HttpContext.User;

            layoutService.SetData(req, resp, user);
        }
Beispiel #2
0
        ///sets the layout atomatically for every get request
        ///we don't render on POST when the model state is valids
        ///
        ///is there is extra logic in the future when we render when
        ///even on valid model, this code needs to change
        public void OnActionExecuting(ActionExecutingContext context)
        {
            var valid  = context.ModelState.IsValid;
            var method = context.HttpContext.Request.Method;

            if (method == "POST" && valid == true)
            {
                return;
            }

            var req  = context.HttpContext.Request;
            var resp = context.HttpContext.Response;
            var user = context.HttpContext.User;

            layoutService.SetData(req, resp, user);
        }