public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            Core.Controllers.ControllerBase controller = filterContext.Controller as Core.Controllers.ControllerBase;

            if (controller != null && !controller.ViewData.ModelState.IsValid)
            {
                if ((filterContext.Result is RedirectResult) || (filterContext.Result is RedirectToRouteResult))
                {
                    IEnumerable <ModelStateWrapper> modelStateWrappers = controller.ViewData.ModelState.Select(
                        ms => new ModelStateWrapper()
                    {
                        Key             = ms.Key,
                        Value           = ms.Value.AttemptedValue,
                        ValidationState = ms.Value.ValidationState
                                          //Errors = ms.Value.Errors.Select(e => e.ErrorMessage)
                    }
                        );

                    controller.TempData[Key] = JsonConvert.SerializeObject(modelStateWrappers, Formatting.None, new JsonSerializerSettings()
                    {
                        ContractResolver = new NoCultureInfoResolver()
                    });
                }
            }

            base.OnActionExecuted(filterContext);
        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            Core.Controllers.ControllerBase controller = filterContext.Controller as Core.Controllers.ControllerBase;

            if (controller != null)
            {
                string serializedModelState = controller.TempData[Key] as string;

                if (!string.IsNullOrEmpty(serializedModelState))
                {
                    IEnumerable <ModelStateWrapper> modelStateWrappers = JsonConvert.DeserializeObject <IEnumerable <ModelStateWrapper> >(serializedModelState, new JsonSerializerSettings()
                    {
                        Error = DeserializationErrorHandler
                    });

                    if (modelStateWrappers != null)
                    {
                        if (filterContext.Result is ViewResult)
                        {
                            foreach (ModelStateWrapper modelStateWrapper in modelStateWrappers)
                            {
                                controller.ViewData.ModelState.SetModelValue(modelStateWrapper.Key, modelStateWrapper.Value, modelStateWrapper.Value);
                                controller.ViewData.ModelState[modelStateWrapper.Key].ValidationState = modelStateWrapper.ValidationState;

                                //if (modelStateWrapper.ValidationState == ModelValidationState.Invalid)
                                //  foreach (string error in modelStateWrapper.Errors)
                                //    controller.ViewData.ModelState[modelStateWrapper.Key].Errors.Add(new ModelError(error));
                            }
                        }

                        else
                        {
                            controller.TempData.Remove(Key);
                        }
                    }
                }
            }

            base.OnActionExecuted(filterContext);
        }