Recaptcha in Umbraco 8

I use a simple recaptcha helper which i call from the controller, to verify the result with. 

public class CaptchaHelper : IInjected
        private readonly UmbracoHelper umbracoHelper;

        public CaptchaHelper(UmbracoHelper umbracoHelper)
            this.umbracoHelper = umbracoHelper;

        public string AuthenticateRecaptcha(string response)
            string secretKey =  umbracoHelper.GetDictionaryValue("Google Captcha Secret Key");

            var webClient = new WebClient();
            var reply =
                secretKey, response));
            return reply;
    public class CaptchaResponse
        public bool Success { get; set; }

        public List<string> ErrorCodes { get; set; }

When i call the code, for example in my mail helper, i call the helper, and pass the request. And then check on the success status of the response.

string reply = captchaHelper.AuthenticateRecaptcha(Request["g-recaptcha-response"]);
                var captchaResponse = JsonConvert.DeserializeObject<CaptchaResponse>(reply);

                if (captchaResponse.Success)

Leave a Reply

Your email address will not be published. Required fields are marked *