Validating recaptcha on server side

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#.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

Method 2

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.

Method 3

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.

Method 4

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x