Giter Site home page Giter Site logo

brandcaptcha-plugin-net's Introduction

#Using BrandCAPTCHA with ASP.NET

The BrandCAPTCHA ASP.NET Library provides a simple way to place a BrandCAPTCHA on your ASP.NET website, helping you stop bots from abusing it. The library wraps the BrandCAPTCHA API.

After you've obtained your API keys, you can continue with the setup of the BrandCAPTCHA library in your website.

##ASP.NET

Add a reference to the library Brandcaptcha.dll in your project.

Insert the BrandCAPTCHA control inside the form you want to protect:

At the beginning of your aspx file, insert the code below:

<%@ Register TagPrefix="brandcaptcha" Namespace="Brandcaptcha" Assembly="Brandcaptcha" %>

Then insert the BrandCAPTCHA control inside the <form runat="server"> tag:

<brandcaptcha:BrandCaptchaControl
    ID="brandcaptcha"
    runat="server"
    PublicKey="your_public_key"
    PrivateKey="your_private_key"
    />

You will need to replace your_public_key and your_private_key values with the keys provided, or you can set them inside your configuration file.

Be sure to use the ASP.NET validations to validate your form (check Page.IsValid on submit).

##ASP.NET MVC

Add a reference to the library Brandcaptcha.dll in your project.

Insert the BrandCAPTCHA control inside the form you want to protect:

At the beginning of your view, insert the code below:

@using Brandcaptcha;

Then insert the BrandCAPTCHA control inside the <form>:

@Html.Raw(Html.GenerateCaptcha())

You will need to set the PublicKey and PrivateKey properties of the BrandcaptchaControlMvc class with your public key and private key, or you can set them inside your configuration file.

To validate the BrandCAPTCHA, you will need to add the BrandcaptchaControlMvc.CaptchaValidator attribute and the captchaValid and captchaErrorMessage parameters to the action you want to protect. Below is an example code in c#:

[HttpPost]
[BrandcaptchaControlMvc.CaptchaValidator]
public ActionResult FormPostAction(bool captchaValid, string captchaErrorMessage)
{
	
}

##Configuration file

You can set your public and private key inside your application's configuration file, using BrandCaptchaPublicKey and BrandCaptchaPrivateKey inside the appSettings section:

<appSettings>
	<add key="BrandcaptchaPublicKey" value="your_public_key" />
	<add key="BrandcaptchaPrivateKey" value="your_private_key"/>
</appSettings>

brandcaptcha-plugin-net's People

Contributors

cbellucci avatar gomezdanielg avatar mdominoni avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.