tanveery / recaptcha-net

reCAPTCHA for .NET library lets you easily use Google's reCAPTCHA in an ASP.NET Web Forms / MVC / ASP.NET Core application.
Apache License 2.0
161 stars 68 forks source link

An object reference is required for the non-static field, method, or property 'RecaptchaVerificationResult.Success' #75

Closed jermifer closed 11 months ago

jermifer commented 1 year ago

Using ASP.NET Framework 4.72 MVC When upgrading the RecaptchaNet package from 2.1.0 to 3.0.0 or 3.1.0, this error starts appearing.

I'm following the implementation provided in the documentation. RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse(); if (recaptchaResult != RecaptchaVerificationResult.Success) { this.ModelState.AddModelError(errorMsgId, CatpchaError); }

jermifer commented 11 months ago

The correct implementation:

RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
if (!recaptchaResult.Success) {
  ModelState.AddModelError(errorMsgId, catpchaError);
}