【发布时间】:2013-04-12 20:11:35
【问题描述】:
我在 asp.net 4.0 网络应用程序中使用 MSCaptcha 控件。我已将提供的 .dll 和 .xml 文件放在 Bin 文件夹中,并在页面顶部添加了<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>。
这是我在页面中使用它的方式:
<cc1:CaptchaControl ID="Captcha1" runat="server"
CaptchaBackgroundNoise="Low" CaptchaLength="4"
CaptchaHeight="60" CaptchaWidth="300"
CaptchaLineNoise="None" CaptchaMinTimeout="1"
CaptchaMaxTimeout="240" FontColor = "#529E00" />
在后面的代码中我这样使用它:
If Page.FindControl("Captcha1").ToString = "MSCaptcha.CaptchaControl" Then
Captcha1.ValidateCaptcha(webCaptcha.Text.Trim())
If Captcha1.UserValidated Then
addComment()
Else
webWrongCaptcha.Text = "Captcha is wrong!"
End If
Else
Response.Redirect("contact.aspx?c=e")
End If
但是如果用户在CaptchaMaxTimeout 之后单击按钮,我会遇到此错误:
Line 7: Captcha1.ValidateCaptcha(webCaptcha.Text.Trim())
我该如何解决?
【问题讨论】:
-
null是什么:Captcha1、webCaptcha或webCaptcha.Text? -
不是
webCaptcha也不是webCaptcha.Text,但不确定Captcha1 -
因为我尝试了
Captcha1.ValidateCaptcha("foo")并遇到了同样的错误。 -
针对另一个类似查询stackoverflow.com/questions/17232819/…提供的答案
标签: asp.net