Comments (8)
It seems that from 2.2.5 to 3.0.0 the syntax changed:
@(Html.Recaptcha(recaptchaSettings.Value))
should be
@(Html.Recaptcha<RecaptchaV3HiddenInput>(recaptchaSettings.Value))
I think.
See this part of README for more info.
from recaptcha.aspnetcore.
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?
from recaptcha.aspnetcore.
@radl97 Yep, I know. I'm using it exactly in the same way as it described in documentation including version type parameters.
from recaptcha.aspnetcore.
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
from recaptcha.aspnetcore.
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:
@(Html.Recaptcha<RecaptchaV3HiddenInput>(recaptchaSettings.Value, MyRecaptchaV3HiddenInputModel))
from recaptcha.aspnetcore.
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 Html.Recaptcha<T>
.
from recaptcha.aspnetcore.
This should now be resolved in 3.0.1. Please reopen this issue if it persists. Thanks to everyone for assistance provided.
from recaptcha.aspnetcore.
Hi Tim,
I am hitting this issue in my code.
Installed version: 3.0.10
Controller has it injected:
public ServiceController(RheaWebsiteDB db, IRecaptchaService recaptcha) //injecting the dbcontext { _db = db; this._recaptcha = recaptcha; }
The relevant action code:
[HttpPost] //TODO: Removed this because it doesn't work anymore , Recaptcha.RecaptchaControlMvc.CaptchaValidator] [ValidateRecaptcha] public async Task<ActionResult> RequestAQuote(Quote quote, bool captchaValid, string captchaErrorMessage) { var recaptcha = await _recaptcha.Validate(Request); if (!recaptcha.success) ModelState.AddModelError("captcha", captchaErrorMessage);
The code in the view:
`@using reCAPTCHA.AspNetCore
@using reCAPTCHA.AspNetCore.Versions
@using Microsoft.Extensions.Options
@Inject IOptions RecaptchaSettings
----other stuff
<div>
@(Html.Recaptcha<RecaptchaV3HiddenInput>(RecaptchaSettings?.Value))
@Html.ValidationMessage("captcha")
</div>
`
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')
reCAPTCHA.AspNetCore.Templates.RecaptchaV3HiddenInputBase+ToStringInstanceHelper.ToStringWithCulture(object objectToConvert)
reCAPTCHA.AspNetCore.Templates.RecaptchaV3HiddenInput.TransformText()
reCAPTCHA.AspNetCore.RecaptchaHelper.Recaptcha(IHtmlHelper helper, RecaptchaSettings settings, T model)
AspNetCore.Areas_Services_Views_Service_RequestAQuote.ExecuteAsync() in RequestAQuote.cshtml
+
@(Html.Recaptcha(RecaptchaSettings.Value, new RecaptchaV3HiddenInput()))
Thank you
from recaptcha.aspnetcore.
Related Issues (20)
- v3 Recaptcha is timing out after 120 seconds and cannot be used anymore
- NotSupportedException: Deserialization of reference types without parameterless constructor is not supported. Type 'reCAPTCHA.AspNetCore.RecaptchaResponse'
- Reusable filters should not use transient DI
- Incorrect Content-Type: application/json; HOT 1
- AddRecaptcha method should be inside Microsoft.Extensions.DependencyInjection HOT 4
- Cannot localize the error message HOT 2
- Using it in Ajax form, unvalid modelstate HOT 1
- Html Recaptcha g-recaptcha-response value empty string HOT 10
- Implementation on Razor Pages HOT 1
- Recaptcha score configurable from appsettings HOT 1
- Problem with Razor Pages HOT 1
- Validation is failing after upgrading asp.net core project from v2.2 to 3.1 HOT 3
- Validation is failing constantly HOT 2
- Recaptcha in controller of web api HOT 1
- Prevent Exception when recaptcha isn't at form
- Cannot validate recaptcha in cloud app behind Azure app gateway HOT 2
- [Q]: Can you render a full challenge in V3 if user fails the score? HOT 2
- CSP can't be really used HOT 1
- Usage with .Net Framework 4.8
- Cannot submit with "submit JS script" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recaptcha.aspnetcore.