TimothyMeadows / reCAPTCHA.AspNetCore

Google reCAPTCHA v2/v3 for .NET Core 3.x
MIT License
144 stars 51 forks source link

Validation is failing constantly #88

Closed Chandinipt closed 3 years ago

Chandinipt commented 3 years ago

Hi @TimothyMeadows ,

I am trying to use your package for recaptcha on my site.

Microsoft.AspNetCore- 2.2.0 Recaptcha.aspnetcore - 3.0.10

I have followed your example as is. This is what I have in my controller:

        [ValidateRecaptcha]
        public async Task<ActionResult> Contact_Form(Feedback fb)
        {
           var recaptcha = await _recaptcha.Validate(Request);
            if (!recaptcha.success)  //  || recaptcha.score != 0 && recaptcha.score < _minimumScore)
                ModelState.AddModelError("Recaptcha", _errorMessage);

And this is in my View:

<div class="form-group">
                    @(Html.Recaptcha<RecaptchaV2Checkbox>(RecaptchaSettings.Value))
                    <span class="text-warning"> @Html.ValidationMessage("Recaptcha") </span>
                </div>

`

This is in my Startup.cs file

            // Add recaptcha and pass recaptcha configuration section
            services.AddRecaptcha(Configuration.GetSection("RecaptchaSettings"));

Whether I click on the recaptcha checkbox or not, the 'recaptcha.success' value is always false. can you help resolve this please? Am I doing something wrong?

Thank you

vas7n commented 3 years ago

try disabling async

@(Html.Recaptcha<RecaptchaV3HiddenInput>(RecaptchaSettings?.Value, new RecaptchaV3HiddenInput { IsAsync = false }) )

TimothyMeadows commented 3 years ago

Marking this closed due to age, and comment above. Please re-open should you still need help.