public override void Process(TagHelperContext context, TagHelperOutput output) { if (CaptchaMiddleware.CanOption(CodeName, ViewContext.HttpContext.Session)) { output.SuppressOutput(); } }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { var httpContextAccessor = CaptchaMiddleware.ApplicationServices.GetService <IHttpContextAccessor>(); var session = httpContextAccessor.HttpContext.Session; if (CanOption && CaptchaMiddleware.CanOption(CodeName, session)) { return(ValidationResult.Success); } else { var codeValue = session.GetString(CaptchaMiddleware.SessionKeyPrefix_Value + CodeName); return(Valid(value, codeValue)); } }