Validating recaptcha on server side

2019-02-19 09:42发布

I am using Google recaptcha in one of our projects. I added the recaptcha control in aspx page. Now i want to validate the value entered in recaptcha that is whether it is correct or not. How can i done it in a button click event? I am using c#.

4条回答
聊天终结者
2楼-- · 2019-02-19 10:14

Apparently it doesn't work with ASP.NET ValidationGroups. If you have a ValidationGroup, you need to call recaptcha.Validate() manually before checking recaptcha.IsValid or Page.IsValid.

查看更多
Melony?
3楼-- · 2019-02-19 10:18
if(Page.IsValid) //Will be true if captcha text is correct otherwise it will be false
{
 //***your code****

}

Edit: call Page.Validate() before checking condition

查看更多
男人必须洒脱
4楼-- · 2019-02-19 10:36

If you're using the ASP.NET reCaptcha control, you need to manually call

recaptcha.Validate()

before you check the recaptcha.IsValid or Page.IsValid properties.

查看更多
Ridiculous、
5楼-- · 2019-02-19 10:37

C# must use recaptcha.Validate() depois you can use check if Page.IsValid

查看更多
登录 后发表回答