Closed robs23 closed 2 years ago
Hi, I had a look at your code and it looks like you're using reCAPTCHA v3 based on the generated html. For reCAPTCHA v3 the only indicator is indeed the badge that says the site is protected. However in this case the submit button cannot be a standard but should be a button with some extra attributes (see https://developers.google.com/recaptcha/docs/v3#automatically_bind_the_challenge_to_a_button). (I did notice our samples are wrong for V3 though, I'll see if I can fix that).
If you want the "Confirm you're a human" checkbox, you have to change the version to V2 (not V2Invisible as that still wouldn't show it). You can do this with the following appsettings setting:
{
"ReCaptcha": {
"Version": "V2"
}
}
You would also need to change the cshtml to add a case for V2 (it can use the same @Html.ReCaptcha(language: "en")
like you have for V3).
Hope this helps you to get it working.
Hi, thanks for prompt asnwer! I wasn't aware how V3 captchas work, probably I should have checked that first. Anyway, I changed it to V2 and now it's working well. Just wondering, if I would like to stick to V3 captchas, is adding those button's extra attributes the only thing needed? What data-callback should be then? My form's asp-page-handler is "SendMail" code-behind's method
What data-callback should be then?
V3 adds nothing to the frontend, it just invalidates a model and add error to the model if obtained score is under threshold. You should then add a respective logic to the action in the .cs code. Send confirmation code via SMS/Email is a common practice.
submit button cannot be a standard but should be a button with some extra attributes
It's incorrect for this particular implementation for V3. Button should be a standard submit button for submit form. Injected recaptcha will bind to submit action and add its data to the model.
Closing this issue for inactivity. Please re-open this issue when needed.
I don't think it's really an issue but rather something wrong in my code. Anyway, I've been trying to fix it on my own, with a help on forums, unfortunatelly without any luck. So as a last resort I'm asking here, mayble you'll find few minutes to check what's wrong. I have your package installed in Asp.Net Core 3.1 Razor Pages proejct. For some reason, no "Confirm you're a human" checkbox appears (or anything similiar), the only visual confirmation that your package is working is working is ReCaptcha badge saying that site is protected. I'm pretty sure I've done everything according to your instruction, don't know what to ckeck next. Here's the forum post I created (unsolved yet), here's the page I'm having problem with (reCaptcha should be displayed above "Submit" button), and here's source code.