Posts

Showing posts from July, 2018

Develop recaptcha validation in c# backend and website

In Html  <div class="g-recaptcha" data-sitekey="@siteKey"></div>                                     <script src="https://www.google.com/recaptcha/api.js?hl=en" async defer></script> C# backend string EncodedResponse = Request.Form["g-Recaptcha-Response"]; bool IsCaptchaValid = (ReCaptchaClass.Validate(EncodedResponse, secretKey) == "True" ? true : false);  public class ReCaptchaClass     {         public static string Validate(string EncodedResponse, string secretKey)         {             var client = new WebClient();                   var GoogleReply = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, EncodedResponse));       ...