I have a special validation attribute derived from an action filter attribute. For the time being, the attribute simply sets an ActionParameter value indicating whether the checked item was good or not, and then the action should have logic to determine what to do with the information.
public class SpecialValidatorAttribute: ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) {
I would like to execute ModelState.AddModelError (), while in the OnActionExecuting () method, which will save me if the controller executes this logic.
I tried to add the ModelState property for the attribute, but this data does not seem to be available to go into the attribute.
Is there a way to access ModelState from an attribute?
source share