locked
Simple Captcha RRS feed

  • Question

  • User746671234 posted

    Hi, does anyone knows simple captcha for asp.net.  I found many in google but most of them are not working on live server.

    I need simple captcha.

    Friday, July 29, 2016 7:03 PM

Answers

  • User-491950272 posted

    Greetings,

    You can use Google Captcha V2. First get the captcha and they will give you a div element, put this at the required place and now send a web request to the web client as:

    public bool Verify(string encodedResponse)
            {
                var client = new WebClient();
    
                string privateKey = "{put here your private key}";
    
                var GoogleReply = client.DownloadString(string.Format("{put here your verification URL}", privateKey, encodedResponse));
    
                return JsonConvert.DeserializeObject<CaptchaResponse>(GoogleReply).Success; //De-Serialize the JSON to CaptchaResponse.cs Model
    
            }

    Here is the CaptchaReponse.cs class as:

    public class CaptchaResponse
        {
            [JsonProperty("success")]
            public bool Success { get; set; }
    
            [JsonProperty("error-codes")]
            public List<string> ErrorCodes { get; set; }
        }

    The based upon this Success serialized object you can determined that whether the captcha is valid or not. The reponse that you get from the Google is in JSON format.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 30, 2016 10:38 AM
  • User36583972 posted

    Hi  ravininave,

    I found some examples in the below for your reference.

    Simple Captcha with ASP.Net :

    http://www.c-sharpcorner.com/article/simple-captcha-with-Asp-Net/

    How to implement simple Captcha in ASP.Net:

    http://www.dotnetawesome.com/2014/07/how-to-implement-simple-captcha-in-aspnet.html

    How to implement Captcha in ASP.Net:

    http://www.aspsnippets.com/Articles/How-to-implement-Captcha-in-ASP.Net.aspx

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 1, 2016 5:50 AM

All replies

  • User-491950272 posted

    Greetings,

    You can use Google Captcha V2. First get the captcha and they will give you a div element, put this at the required place and now send a web request to the web client as:

    public bool Verify(string encodedResponse)
            {
                var client = new WebClient();
    
                string privateKey = "{put here your private key}";
    
                var GoogleReply = client.DownloadString(string.Format("{put here your verification URL}", privateKey, encodedResponse));
    
                return JsonConvert.DeserializeObject<CaptchaResponse>(GoogleReply).Success; //De-Serialize the JSON to CaptchaResponse.cs Model
    
            }

    Here is the CaptchaReponse.cs class as:

    public class CaptchaResponse
        {
            [JsonProperty("success")]
            public bool Success { get; set; }
    
            [JsonProperty("error-codes")]
            public List<string> ErrorCodes { get; set; }
        }

    The based upon this Success serialized object you can determined that whether the captcha is valid or not. The reponse that you get from the Google is in JSON format.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 30, 2016 10:38 AM
  • User36583972 posted

    Hi  ravininave,

    I found some examples in the below for your reference.

    Simple Captcha with ASP.Net :

    http://www.c-sharpcorner.com/article/simple-captcha-with-Asp-Net/

    How to implement simple Captcha in ASP.Net:

    http://www.dotnetawesome.com/2014/07/how-to-implement-simple-captcha-in-aspnet.html

    How to implement Captcha in ASP.Net:

    http://www.aspsnippets.com/Articles/How-to-implement-Captcha-in-ASP.Net.aspx

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 1, 2016 5:50 AM