BotDetect ASP.NET CAPTCHA Generator

CAPTCHA Generator Features:

Quickstarts:

BotDetect ASP.NET Captcha generator allows you to easily add Captcha protection to various types of ASP.NET based forms.

We'll use default Captcha generator settings; to see how powerful and customizable BotDetect is, check the BotDetect features demo.

ASP.NET MVC 5 CAPTCHA / C#

1. Add a Reference to BotDetect

Both the BotDetect.dll and BotDetect.Web.Mvc.dll assemblies should be referenced. They are included in the BotDetect installation.

2. Show a Captcha Challenge on the Form

In View code: import the BotDetect namespace, include BotDetect styles in page <head>, create a MvcCaptcha object and pass it to the Captcha HtmlHelper:
@using BotDetect.Web.Mvc;

  […]

  <link href="@BotDetect.Web.CaptchaUrls.Absolute.LayoutStyleSheetUrl"
    rel="stylesheet" type="text/css" />
</head>

  […]

@{ MvcCaptcha exampleCaptcha = new MvcCaptcha("ExampleCaptcha"); 
exampleCaptcha.UserInputID = "CaptchaCode";}
@Html.Captcha(exampleCaptcha)
@Html.TextBox("CaptchaCode")

3. Check User Input During Form Submission

Mark the protected Controller action with the CaptchaValidation attribute to include Captcha validation in ModelState.IsValid checks:
using BotDetect.Web.Mvc;
  
  […]

[HttpPost]
[AllowAnonymous]
[CaptchaValidation("CaptchaCode", "ExampleCaptcha", "Incorrect CAPTCHA code!")]
public ActionResult ExampleAction(ExampleModel model)
{
    if (!ModelState.IsValid)
    {  
      // TODO: Captcha validation failed, show error message      
    }  
    else
    {  
      // TODO: Captcha validation passed, proceed with protected action  
    }  

4. Configure Your ASP.NET Application

Exclude BotDetect paths from ASP.NET MVC Routing:
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    // BotDetect requests must not be routed
    routes.IgnoreRoute("{*botdetect}", 
      new { botdetect = @"(.*)BotDetectCaptcha\.ashx" });
Update your application configuration (the web.config file):
<system.web>
  <httpHandlers>
    <!-- Register the HttpHandler used for BotDetect Captcha 
      requests -->
    <add verb="GET" path="BotDetectCaptcha.ashx"
      type="BotDetect.Web.CaptchaHandler, BotDetect"/>
  </httpHandlers>
  <!-- Register a custom SessionIDManager for BotDetect Captcha 
    requests -->
  <sessionState mode="InProc" cookieless="AutoDetect" timeout="20" 
    sessionIDManagerType="BotDetect.Web.CustomSessionIdManager, BotDetect"/> 
</system.web>
<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <handlers>
    <!-- Register the HttpHandler used for BotDetect Captcha 
      requests (IIS 7.0+) -->
    <remove name="BotDetectCaptchaHandler"/>
    <add name="BotDetectCaptchaHandler" preCondition="integratedMode" 
      verb="GET" path="BotDetectCaptcha.ashx"
      type="BotDetect.Web.CaptchaHandler, BotDetect"/>
  </handlers>
</system.webServer>

In-Depth ASP.NET MVC CAPTCHA Instructions and Explanations

Detailed ASP.NET MVC Captcha instructions and explanations can be found in the ASP.NET MVC Captcha integration how to guide.

BotDetect ASP.NET CAPTCHA Free Version

You can download BotDetect ASP.NET CAPTCHA Control for free and use it immediately! Your ASP.NET forms can be protected from spam (and bots in general) in minutes.

Keep in mind that we offer basic email support for free to all BotDetect users. So if you need any assistance integrating BotDetect or have any questions or feedback, our Support department is at your disposal.

Once the BotDetect Captcha generator control has been integrated into your ASP.NET application and you're satisfied with how it works, it's easy to upgrade your license if you need the extra features and options offered by commercial BotDetect versions.

BotDetect ASP.NET Captcha Free Download

BotDetect ASP.NET CAPTCHA System Requirements

OS IIS .NET

Supported Operating Systems:

  • Windows 2016 Server
  • Windows 10
  • Windows 2012 Server R2
  • Windows 2012 Server
  • Windows 8
  • Windows 2008 Server R2
  • Windows 7
  • Windows 2008 Server
  • Windows Vista
  • Windows 2003 Server
  • Windows XP
  • Windows 2000 Server
  • Windows 2000 Professional

Supported Internet Information Services:

  • IIS 10
  • IIS 8.5
  • IIS 8.0
  • IIS 7.5
  • IIS 7.0
  • IIS 6.0
  • IIS 5.1
  • IIS 5.0

Supported .NET Framework versions:

  • .NET 4.6
  • .NET 4.5
  • .NET 4.0
  • .NET 3.5
  • .NET 3.0
  • .NET 2.0
  • .NET 1.1 (*)

* .NET 1.1 is supported by previous generation releases (BotDetect v2.0), which can be obtained on request.