Skip to content

netdragoon/ReCaptchaNet

Repository files navigation

Canducci ReCAPTCHA

Travis NuGet

##NUGET

PM> Install-Package CanducciReCaptchaMvc

##How to?

In web.config add these 4 keys referring to Google Api (Captcha-Site-Key, Captcha-Secrety-Key, Captcha-Site-Verify-Url and Captcha-Api-Url). Make your registration in https://www.google.com/recaptcha/intro/index.html site and add the settings the site key(Captcha-Site-Key) and secret key(Captcha-Secrety-Key).

<configuration>
  <appSettings>
    ...
    <add key="Captcha-Site-Key" value=""/>
    <add key="Captcha-Secrety-Key" value=""/>
    <add key="Captcha-Site-Verify-Url" value="https://www.google.com/recaptcha/api/siteverify"/>
    <add key="Captcha-Api-Url" value="https://www.google.com/recaptcha/api.js"/>  
  </appSettings>

Use namespace using Canducci.ReCAPTCHA;

###Controller

[HttpGet()]
public ActionResult Site()
{            
	return View();
}

[HttpPost()]
public ActionResult Site(ReCaptchaResponse ReCaptchaResponse)
{
	
	if (ReCaptchaResponse.Success)
	{
		//validation passed    
	}
	else
	{
		//validation errors
	}

	return View();
}

###View

In html tag in the Head call the razor method Html.ReCaptchaScript

<head>
    ....
    @Html.ReCaptchaScript(Render.Onload, ReCaptchaLanguage.Portuguese_Brazil)    
</head>

Body call the razor method Html.ReCaptcha()

<form method="post">            
    <div style="height:100px;">
        @Html.ReCaptcha()
    </div>
    <button class="btn btn-primary">Send</button>
</form>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages