-
Notifications
You must be signed in to change notification settings - Fork 50
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
Unhandled exception while using reCAPTCHA.AspNetCore v3 #46
Comments
It seems that from 2.2.5 to 3.0.0 the syntax changed:
should be
I think. See this part of README for more info. |
Just hit the exact same issue :) Could this be related to some culture/resource file thing or a new behavior around stringifying things? It seems, from quickly looking into the Templates file, that it fails in a null check here (https://github.com/TimothyMeadows/reCAPTCHA.AspNetCore/blob/master/reCAPTCHA.AspNetCore/Templates/RecaptchaV3HiddenInput.cs#L307) so maybe the new stuff requires you to always provide language and actions? |
@radl97 Yep, I know. I'm using it exactly in the same way as it described in documentation including version type parameters. |
Not sure if this helps, but my error was incorrectly reading from the appSettings/appConfig. Once I got that sorted, I no longer hit this issue |
Will look into this today as time permits. It's likely it might be related to Action not being supplied. The new version moved from using functional programming to more model based. In the event it's missing a value you can always specify a constructed model yourself here:
|
Looks like this is from 2 reasons: The second reason seems to have been resolved but will add it here anyway just for someone reading this. The first is there is no default for Actions in V3 when it should be defaulted to "homepage". This will be resolved in the next version. You can fix this now by specifying a constructed model yourself rather than depending on the class model defaults. The second issue is the original code you posted here is not using T to specify your version. I know you resolved this but this is likely be the most common issue coming from 2 to 3 for users reading. You no long use "Version": "" in JSON to denote which version of recaptcha the library is using. Please check the docs and use the correct model in |
This should now be resolved in 3.0.1. Please reopen this issue if it persists. Thanks to everyone for assistance provided. |
Hi Tim, Controller has it injected:
The relevant action code: The code in the view: `@using reCAPTCHA.AspNetCore @Inject IOptions RecaptchaSettings ----other stuff
` Have also tried supplying a new RecaptchaV3HiddenInput() object to the Html.recaptcha call. And changing it to version RecaptchaV2Checkbox. But still hitting the ArgumentNullException as shown below: ArgumentNullException: Value cannot be null. (Parameter 'objectToConvert') Thank you |
Installed version: 3.0.0
Project type: netcoreapp3.1
ArgumentNullException: Value cannot be null. (Parameter 'objectToConvert')
reCAPTCHA.AspNetCore.Templates.RecaptchaV3HiddenInputBase+ToStringInstanceHelper.ToStringWithCulture(object objectToConvert)
reCAPTCHA.AspNetCore.Templates.RecaptchaV3HiddenInput.TransformText()
reCAPTCHA.AspNetCore.RecaptchaHelper.Recaptcha(IHtmlHelper helper, RecaptchaSettings settings, T model)
AspNetCore.Views_SupplierRequest_Index.ExecuteAsync() in Index.cshtml
+
@(Html.Recaptcha(recaptchaSettings.Value))
appSettings.config:
"RecaptchaSettings": {
"SecretKey": "some_key",
"SiteKey": "some_key",
"Version": "v3" // tried to remove this line but exception is the same
},
The text was updated successfully, but these errors were encountered: