Custom validator non bloquant
Bonjour,
J'utilise un custom validator pour valider un ReCaptcha de google.
Code:
1 2 3
|
<recaptcha:RecaptchaControl runat="server" ID="captcha" PrivateKey="key" PublicKey="key" />
<asp:CustomValidator ID="vldCustom" runat="server" ValidationGroup="vld-register" OnServerValidate="vldCustom_ServerValidate" ErrorMessage="Le captcha est incorrect.">*</asp:CustomValidator> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
protected void vldCustom_ServerValidate(object source, ServerValidateEventArgs args)
{
Recaptcha.RecaptchaValidator val = new Recaptcha.RecaptchaValidator();
val.Challenge = Request.Form["recaptcha_challenge_field"];
val.Response = Request.Form["recaptcha_response_field"];
val.RemoteIP = Request.ServerVariables["LOCAL_ADDR"];
val.PrivateKey = "KEY";
val.Proxy = new WebProxy("proxy", 8080) {Credentials = new NetworkCredential("user","pass")};
Recaptcha.RecaptchaResponse reponse = val.Validate();
args.IsValid = reponse.IsValid;
} |
Quand le args.IsValid est bien mis a FALSE, la validation continue quand même.
Savez vous comment régler ce probleme ?
Merci d'avance,
Félix