Quantcast
Channel: Security Vulnerability
Viewing all articles
Browse latest Browse all 317

asp.net WebForms Ajax Recaptcha .Validate() is always returning false

$
0
0

I used this exact same technique before and it always worked.  For some reason when I'm doing this now the isvalide is always returning false.  Can anyone explain this?  Any help would be great.  Every variation I try still returns a fail.

Thanks!
 

<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>
<recaptcha:RecaptchaControl ID="recaptcha"
                                                runat="server"
                                                Theme="clean"
                                                PublicKey="public key string"
                                                PrivateKey="private key string"
                                                EnableViewState="true"
                                                /><br /><a href="Javascript:frmOnSubmit();" id="lnkSubmit" runat="server" class="button">Submit</a>

<script type="javascript">


        function frmOnSubmit() {
            var challengeField = $("input#recaptcha_challenge_field").val();
            var responseField = $("input#recaptcha_response_field").val();
            if (responseField.length == 0) {
                alert('* Must enter a value for Verfication.');
            } else {
                var postData = { 'chall': '\'' + challengeField + '\'', 'response': '\'' + responseField + '\'' };$.ajax({
                    type: "post"
                    , url: 'ReCaptchaExample.aspx/CheckCaptcha'
                    , data: JSON.stringify(postData)
                    , contentType: "application/json; charset=utf-8"
                    , dataType: "json"
                    , success: function (data, st) {
                        Recaptcha.reload();
                        if (st == "success") {
                            alert(data.d);
                        } else {
                            alert("Not Pass");
                            return false;
                        }
                    }, error: function (data, st) {
                        Recaptcha.reload();$('#lblMessage2').html('* There was an issue with the form.')
                        return false;
                    }
                });
            }
        }</script>
        [WebMethod]
        public static string CheckCaptcha(string chall, string response) {
            Recaptcha.RecaptchaValidator captchaValidtor = new Recaptcha.RecaptchaValidator {
                PrivateKey = "private key string",             
                RemoteIP = HttpContext.Current.Request.UserHostAddress,
                Challenge = chall,
                Response = response
            };

            Recaptcha.RecaptchaResponse recaptchaResponse = captchaValidtor.Validate(); 
            return (recaptchaResponse.IsValid) ? "pass" : "fail"; 

        }

Viewing all articles
Browse latest Browse all 317

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>