There is an attribute in the model to the property for checking the captcha. The captcha text is stored in the session context.HttpContext.Session.GetString("CaptchaCode"); Trying to do this:
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { RegisterFizikModel.InputModel inputModel = (RegisterFizikModel.InputModel)validationContext.ObjectInstance; _captcha = validationContext.HttpContext.Session.GetString("CaptchaCode"); if (inputModel.Captcha != _captcha) { return new ValidationResult(GetErrorMessage()); } return ValidationResult.Success; } The error turns out:
ValidationContextdoes not containHttpContext
How can I get the value of HttpContext.Session.GetString from the session in the property attribute?
IModelValidatoryour attribute class implementIModelValidator? - Andrew NOP