Skip to content

xsoheilalizadeh/reCaptcha.Google.Mvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reCaptcha.Google.Mvc

Install Nuget Package:

Install-Package reCaptcha.Google.Mvc

Documention

Configure Captcha

In Global.asax file and Application_Start method you can config Google reCaptcha:

GoogleCaptchaConfiguration.Register(new GoogleCaptchaConfig(CaptchaTheme.Light)
{
    EnableInDebuggingMode = false,
    Secretkey = "yourSecretkey",
    Sitekey = "yourSitekey",
});

Usage

To render Captcha use Html.RenderCaptcha():

@Html.RenderCaptcha()
@Html.RenderCaptcha("siteKey") // also you set Sitekey here

To render Captcha script use Html.RenderCaptchaScript():

@Html.RenderCaptchaScript()

To validation request use GoogleCaptcha on the action method:

[HttpPost]
[Route("sign-up")]
[GoogleCaptcha]
public ActionResult Register()
{
    // more code
}