Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reCaptcha not validating #40

Open
mohsin1122 opened this issue Apr 3, 2020 · 3 comments
Open

reCaptcha not validating #40

mohsin1122 opened this issue Apr 3, 2020 · 3 comments

Comments

@mohsin1122
Copy link

Hi
i have integrated reCaptcha but when i submit without clicking reCaptcha the controller is not validating it .

placed: [ValidateRecaptcha] above the method in controller as described in getting started page but it is not validating

@vanpyrzericj
Copy link

@mohsin1122 Can you provide more context, in order for folks to help you diagnose the issue?

You registered the service in Startup.cs correct?

In your controller, when you submit without clicking the recaptcha, ModelState..IsValid is still evaluating to true?

How are you placing the recaptcha on your page? Are you using the tag helper? Or are you putting your own version of recaptcha on the page? Are you submitting the form to the controller, or are you manually doing an AJAX call?

@mohsin1122
Copy link
Author

Hi.
yes ModelState.IsValid is false but as per my understanding we use attribute based validation to avoid entering method body that is why i think it is not working.

Startup.cs
services.AddRecaptcha(new RecaptchaOptions { SiteKey = Configuration["Recaptcha:SiteKey"], SecretKey = Configuration["Recaptcha:SecretKey"] });

yes i am using <recaptcha /> tag helper. also this is not an AJAX call

@christianhanvey
Copy link

christianhanvey commented Apr 15, 2020

@mohsin1122 I had a similar issue when adding to a razor page and the attribute was added only to the OnPost method. Moving the [ValidateRecaptcha] attribute to the class rather than the method solved the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants