Share via


ReCaptcha Class

Generates a CAPTCHA test that is based on the reCAPTCHA service.

Inheritance Hierarchy

System.Object
  Microsoft.Web.Helpers.ReCaptcha

Namespace:  Microsoft.Web.Helpers
Assembly:  Microsoft.Web.Helpers (in Microsoft.Web.Helpers.dll)

Syntax

'Declaration
Public NotInheritable Class ReCaptcha
'Usage
You do not need to declare an instance of a static class in order to access its members.
public static class ReCaptcha
public ref class ReCaptcha abstract sealed
public final class ReCaptcha

The ReCaptcha type exposes the following members.

Properties

  Name Description
Public propertyStatic member PrivateKey Gets or sets a private key for the reCAPTCHA service.
Public propertyStatic member PublicKey Gets or sets the public key for the reCAPTCHA service.

Top

Methods

  Name Description
Public methodStatic member GetHtml Render a reCAPTCHA control.
Public methodStatic member GetHtmlWithOptions Render a reCAPTCHA control and enable the caller to pass additional rendering options.
Public methodStatic member Validate Returns a value that indicates whether the user is validated.

Top

Remarks

This class represents a helper, which is a component that simplifies Web programming in ASP.NET Web Pages. You can use the ReCaptcha class to help protect against malicious computer programs that make automated attacks on Web sites. The class generates a CAPTCHA, which is a test that checks user input based on the reCAPTCHA service. To use the service, you must register at the reCAPTCHA Web site (https://www.recaptcha.net) and obtain public and private keys.

A CAPTCHA test validates that user input is submitted by a human rather than a computer program. This helps prevent typical automated attacks such as adding spam comments to blogs or forums, or creating false user accounts on Web sites. A typical CAPTCHA test generates random text in the form of a distorted graphic image, which humans can read but computer programs cannot. If users correctly submit the randomly generated text shown in the distorted image, the CAPTCHA validates them.

To use the ReCaptcha class to help protect your Web site against automated attacks, use the following steps at the points where the code validates user input (such as when it creates a new account or logs in a user):

  1. Render the reCAPTCHA control. This is the form that displays a graphic image of words and prompts users to submit the correct text values. Call the GetHtml(String, String, String, Int32) method or the GetHtmlWithOptions(String, Object) method to render the reCAPTCHA control.

  2. Validate the user input. Call the Validate(String) method to verify that the input passes the CAPTCHA test. If the method returns true, the code can allow the user to continue. If the method returns false, the code can take another action such as notifying the user that the input was incorrect and prompting the user to try again.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Web.Helpers Namespace