Hi @Robert Barnes,
You can use the MSCaptcha Library in ASP.Net.
In order to use MSCaptcha control, you will need to add reference of MSCaptcha Library and then register on the Page as shown below.
<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>
Web.Config Modifications:
<configuration>
//ADD
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.8" />
//ADD
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
<httpRuntime targetFramework="4.8" />
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
//ADD
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="MSCaptcha.captchaImageHandler" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" resourceType="Unspecified"/>
</handlers>
</system.webServer>
</configuration>
Demo
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<cc1:CaptchaControl ID="captcha1" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="200" CaptchaLineNoise="None" CaptchaMinTimeout="5"
CaptchaMaxTimeout="240" FontColor="#529E00" ErrorInputTooFast="Image text was typed too quickly. " ErrorInputTooSlow="Image text was typed too slowly." EnableViewState="False" />
<asp:TextBox ID="txtCaptcha" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCaptcha" runat="server" ErrorMessage="*Required"
ControlToValidate="txtCaptcha" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:Label ID="lblMessage" runat="server"></asp:Label>
<br />
<br />
<asp:Button ID="btnVerify" runat="server" Text="Verify" OnClick="OnVerify" />
</div>
</form>
</body>
</html>
Imports System.Drawing
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub OnVerify(sender As Object, e As System.EventArgs)
captcha1.ValidateCaptcha(txtCaptcha.Text.Trim())
If captcha1.UserValidated Then
lblMessage.ForeColor = Color.Green
lblMessage.Text = "Valid"
Else
lblMessage.ForeColor = Color.Red
lblMessage.Text = "InValid"
End If
End Sub
End Class
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.