Skip to content

reCAPTCHA protects you against spam and other types of automated abuse. Here, we explain how to add reCAPTCHA to your site or application.

License

Notifications You must be signed in to change notification settings

srburton/dotNetCore-ReCaptcha

Repository files navigation

License: MIT

ReCaptcha Unofficial v1.0

License: MIT License: MIT License: MIT License: MIT License: MIT License: MIT License: MIT License: MIT License: MIT

Version .NetCore

 2.1, 2.2

Install

>> Install-Package App.Infra.Integration.ReCaptcha
 or
>> dotnet add package App.Infra.Integration.ReCaptcha

Attributes

 [ReCaptcha]
 
 [ReCaptchaIgnore]

TagHelper

Is Taghelper must be inserted inside the <form> in .cshtml files.

  @Html.ReCaptcha()

Configure

To configure the reCAPTCHA you must by this code snippet with your key information, in the file Startup.cs

services
  .AddMvc(options => {
      
      options.Filters.Add(new ReCaptchaActionFilter( reCaptcha => {
          reCaptcha.PublicKey = "you-public";
          reCaptcha.SecretKey = "you-secret";
          reCaptcha.Redirect  = "/access/denied"; /Custom
      }));
  })
 .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

Controller [All Action]

This support package for the reCAPTCHA to validate all Methodos, the more we encourage only use in calls POST, PUT, DELETE Although the GET works.

    [ReCaptcha]
    public class ExampleController : Controller
    {        
        [HttpGet]        
        public IActionResult Index()
        {
            //...
        }        
        
        [HttpGet]        
        public IActionResult Index(object obj)
        {
            //...
        }  
    }        

Action [Ignore]

    [ReCaptcha]
    public class ExampleController : Controller
    {        
        [HttpGet]    
        [ReCaptchaIgnore]
        public IActionResult Index()
        {
            //...
        }   
        
        [HttpPost]   
        public IActionResult Index(object obj)
        {
            //...
        }          
    }        

Action [Unique]

    
    public class ExampleController : Controller
    {        
        [HttpGet]    
        public IActionResult Index()
        {
            //...
        }   
        
        [HttpPost]   
        [ReCaptcha]
        public IActionResult Index(object obj)
        {
            //...
        }          
    }        

Index.cshtml

   <form asp-route="YouRoute" method="post">

    @Html.ReCaptcha()
    
  </form>        

About

reCAPTCHA protects you against spam and other types of automated abuse. Here, we explain how to add reCAPTCHA to your site or application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages