Showing posts from April, 2017

Google reCAPTCHA using HttpClient in ASP.NET

reCAPTCHAis a free service that protects your site from spam and abuse. It uses advanced risk analysis techniques to tell humans and bots apart. With the new API, a significant number of your valid human users will pass the reCAPTCHA challenge without having to solve a CAPTCHA.

Building The Code

Before you start, visit this link and click on the Get reCAPTCHA button and follow the steps.

Let's Get started 

Step 1: Create a class or a method in your controller and add the code below.

        public async Task<string> GetRecaptcha()         {             var response = HttpContext.Current.Request["g-recaptcha-response"];             const string secretKey = "your secret key";             var apiConsumer = new ApiConsumer();             const string url = "";             apiConsumer.BaseUri = new Uri(url);             apiConsumer.ContentType = ApiConsumer.A…