Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • C# code to add google captcha in your web site

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 447
    Comment on it


    Hi Reader !
    From this blog we can learn how to add google captcha in your web site using c# .
    To use a Google Captcha(or reCaptcha) in your web application, you first have to follow below steps :
    1) Open url https://www.google.com/recaptcha/intro/index.html and sign up using your google account
    2) Click on Get reCAPTCHA button to get your reCaptcha public and private keys for your site.
    3) Download the Google Captcha (reCAPTCHA) ASP.NET library (i.e. Recpatcha.dll) via

    Now to insert captcha control in your web application, add below line at the top of your aspx page :

    <%@ Register TagPrefix="googleReCaptcha" Namespace="Recaptcha"  
    Assembly="Recaptcha" %>
    


    And then add control using below lines in the same page (Substitute your recaptcha public and private key you got by following above steps :

    <googleReCaptcha:RecaptchaControl  
                 ID="myrecaptcha" 
                 runat="server" 
                 Theme="blue" 
                 PublicKey="your recaptcha public key"           
                 PrivateKey=" your recaptcha private key " /> 
    


    And then you can add the below ASP.Net(C#) code to your aspx.cs page to check whether the captcha entered by user and that displayed by Google Captcha image is same or not :

    protected void btnCheckCaptcha_Click(object sender, EventArgs e)
        {
            if (myrecaptcha.IsValid)
                lblCaptchaResult.Text = "Captcha is Correct..";
            else
                lblCaptchaResult.Text = "Captcha is Incorrect!!!";
    
            lblCaptchaResult.Visible = true;
        }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: