Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recaptcha being triggered from masterpage control

I have a master page which contains a Login control so that the user can login/logout from any page. However, a couple of content pages require a Recaptcha control. This causes problems because when I try and log in on a page that has the Recaptcha control, the system expects me to enter the words. I'm aware of the lack of validation groups in the Recaptcha control, and the fact that you can't have multiple forms on an ASP.NET page. Is there a way to work around this? A 'hacky' way I can think of, is in the "Login" event, check the page for a Recaptcha control. If one exists, then disable it, otherwise continue. However, that just seems quite inefficient especially when there are quite a few pages and most won't have a Recaptcha control.

like image 788
XSL Avatar asked Oct 25 '22 14:10

XSL


1 Answers

The workaround for this problem is as follows:

  1. Set ValidationGroup to the Login button. reCAPTCHA control will not validate when a button with ValidationGroup set to non-empty is clicked.
  2. On pages that require reCAPTCHA validation, keep the button's ValidationGroup value to non-empty (otherwise, the login fields will be validated as well), but call RecaptchaControl.Validate() manually on the subroutine.

Discussion thread on the official reCAPTCHA dev mailing list.

like image 64
Adrian Godong Avatar answered Nov 08 '22 13:11

Adrian Godong