验证码图像验证:在C#.net和asp.net中

时间:2010-03-03 07:12:19

标签: c# asp.net security captcha

如何使用asp.net表单验证验证码?

4 个答案:

答案 0 :(得分:13)

要了解的几件事情:

这是经过几分钟的搜索 - 我相信你能找到更多。

答案 1 :(得分:2)

答案 2 :(得分:2)

我先用过这个: http://www.codeproject.com/KB/custom-controls/CaptchaControl.aspx

但是我的机器人遇到了大量的垃圾邮件问题。到目前为止,使用ReCaptcha是完美的。

答案 3 :(得分:0)

首先从网上下载MSCaptcha.dll 在工具栏中导入该dll,并在Bin文件夹中添加引用 在aspx文件中编写以下代码

<cc1:CaptchaControl ID="CaptchaControl1" runat="server" 
                                     CaptchaBackgroundNoise="Low" CaptchaLength="6" 
                                     CaptchaHeight="60" CaptchaWidth="200" 
                                     CaptchaLineNoise="None" CaptchaMinTimeout="5" 
                                     CaptchaMaxTimeout="240" FontColor="#529E00"/>
<asp:Label ID="lbl" runat="server" Text="Verification Code *" style="display: inline-block;width: 200px;line-height: 1.8; vertical-align: top; font-size: 12px;font-weight:bold;"></asp:Label>
 <asp:TextBox ID="txtcaptcha" runat="server" Height="22px" Width="325px" style="border: 1px solid #900;"></asp:TextBox>

并在代码后面写入文件

CaptchaControl1.ValidateCaptcha(txtcaptcha.Text.Trim());
     if (CaptchaControl1.UserValidated)
                {
                    lbierror.ForeColor = System.Drawing.Color.Green;
                    lbierror.Text = "Valid";
                }
                else
                {
                    lbierror.ForeColor = System.Drawing.Color.Red;
                    lbierror.Text = "InValid Captacha";
                }

我希望 这将有效