public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (filterContext.Result is ViewResult && filterContext.ActionDescriptor is ControllerActionDescriptor cad)
            {
                var json = filterContext.HttpContext.Session.GetString(cad.ActionName);
                if (!string.IsNullOrEmpty(json))
                {
                    var modelState = ModelStateHelpers.DeserializeModelState(json);
                    filterContext.ModelState.Merge(modelState);
                    filterContext.HttpContext.Session.Remove(cad.ActionName);
                }
            }

            base.OnActionExecuted(filterContext);
        }
        public void OnPageHandlerExecuted(PageHandlerExecutedContext context)
        {
            var pageModel = context.HandlerInstance as PageModel;

            var serializedModelState = pageModel?.TempData[ModelStateTransferAttribute.Key] as string;

            if (serializedModelState != null)
            {
                // Only Import if we are viewing.
                if (context.Result is PageResult)
                {
                    var modelState = ModelStateHelpers.DeserializeModelState(serializedModelState);
                    context.ModelState.Merge(modelState);
                }
                else
                {
                    // Otherwise remove it.
                    pageModel.TempData.Remove(ModelStateTransferAttribute.Key);
                }
            }
        }
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var controller           = context.Controller as Controller;
            var serializedModelState = controller?.TempData[Key] as string;

            if (serializedModelState != null)
            {
                // Only Import if we are viewing.
                if (context.Result is ViewResult || context.Result is PageResult)
                {
                    var modelState = ModelStateHelpers.DeserializeModelState(serializedModelState);
                    context.ModelState.Merge(modelState);
                }
                else
                {
                    // Otherwise remove it.
                    controller.TempData.Remove(Key);
                }
            }

            base.OnActionExecuted(context);
        }