Implement google recaptcha in MVC and Asp.NET application

Step 1: Generate Site Key and Secret Key for recaptcha

Go through the link:

Then generate you Site Key and Secret Key like below image


Google recaptcha

Step 2: Make div like this on your page where you want to implement captcha

<div id=”CaptchaVal” class=”g-recaptcha” data-sitekey=”Your Site Key“></div>

Step 3: Validate you captcha code by this server side code

public static bool ValidateCaptcha(string response)
string secretkey = System.Configuration.ConfigurationManager.AppSettings[“secretkey”];
string secret = secretkey;
var client = new WebClient();
var reply = client.DownloadString(string.Format(“{0}&response={1}”, secret, response));
var captchaResponse = JsonConvert.DeserializeObject<CaptchaResponse>(reply);
return Convert.ToBoolean(captchaResponse.Success);

if any issue you can contact with us on

Leave a Reply

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