RadCaptcha validation fails on SECOND postback

9 posts, 0 answers
  1. Paul Robertson
    Paul Robertson avatar
    78 posts
    Member since:
    May 2010

    Posted 13 Aug 2012 Link to this post

    Hello all

    I am wondering if anybody might be familiar with the cause of an issue I am struggling with: I have a radCaptcha that validates fine on the initial postback, e.g., validating as False if the code is incorrect or missing, but then if the user fails to enter a code on the second attempt, the radCaptcha always validates as True, even after both the radCaptcha Validate method, and then the Page.Validate(<validation group>) method are called. Important to notice here that the validation works as expected after the first postback, it is just afterwards, when the user is required to enter a new code on a second attempt. It appears to me that the radCaptcha's validator does not reset itself, even if IsValid is manually reset to false at the end of the code-behind processing during the first postback. After the second postback, IsValid determinedly is stuck on True, no matter what I do, which makes me suspicious that this is a bug.

    To complicate matters, the radCaptcha control in question is inside an ASCX user control, which is declared in the ASP markup, rather than loaded dynamically, and there are two validation groups on the page in question. Is there any known workaround for this sort of issue, and where should I be calling different methods? At the moment I have radCatcha.Validate and Page.Validate(<group>) in the code-behind handler for the submit button, and additionally, after I realised there was a problem, I have been experimenting with use of radCaptcha.DataBind and switching its Enabled and IsValid methods on and off manually in the Control Load handler, but nothing seems to make any difference. I could do with a pointer in the right direction to troubleshoot this problem. Where would be the recommended places to call different methods in this sort of scenario?

    Thanks if you can assist.

    Regards

  2. Samir Vaidya
    Samir Vaidya avatar
    8 posts
    Member since:
    Feb 2005

    Posted 02 Oct 2012 Link to this post

    I reproduced the same problem with the following steps.  I am using a RadCaptcha control with a ValidationGroup within an ASP.Net Wizard control:

    1. Deliberately enter an incorrect CAPTCHA code
    2. Click on Complete button
    3. Get an invalid error message
    4. Now enter correct CAPTCHA code
    5. Click on Complete button
    6. Once again get an invalid error message
    7. Enter a correct CAPTCHA code a 2nd time
    8. Click on Complete button
    9. Submission completes successfully
    radCaptcha.Validate();
                Page.Validate("submitPayment");
     
                //Verify that the Captcha is valid
                if (!radCaptcha.IsValid)
                {
                    e.Cancel = true;
                }//if
                else if (radCaptcha.IsValid)
                {


    Please advise.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 05 Oct 2012 Link to this post

    Hello Samir,

    I tried to reproduce the problem, but to no avail. You can find attached my test page. Please compare it with your actual project and let me know if I am missing something. This short video shows the RadCaptcha's behavior on my end.

    The reported problem is not a known one, so I will need to reproduce it in order to help you accordingly. Please try modifying the attached sample so that the issue can be examined and open a support ticket to send it for further inspection. If you are not able to do this, you can also prepare and send a simple, fully runnable page that isolates you case.

    Greetings,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 03 Mar 2014 in reply to Samir Vaidya Link to this post

    Hello All,

    well, there is definifly something fishy here. I experiance the same. With version .717 is all works well, but with the later versions there is a problem.

    I have a simple login form, no AJAX panels or stuff, that hides the RadCaptcha initially. When you enter a wrong password, the RadCaptcha is shown and the validation happans server side. 

    Now, it always returns False, the second PB and further. But... when I do a code refresh... it works fine...

    I also cannot reproduce it in a simple project... But who is building that? :-)

    Erik


  6. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 06 Mar 2014 Link to this post

    Hi Erik,

    Please verify that you tried with the latest available version of UI for ASP.NET AJAX (2014.1.225), because you did not mention which are the later versions you tried with.

    Will it be possible to prepare a fully runnable sample that isolates just the logic of your login form so that I can inspect it locally? Since you have tried with a standard scenario, most probably the issue occurs with a specific setup and it is very likely that I will miss something important if I try recreating it from your description.

    I am looking forward to your update on the case.

    Regards,
    Slav
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

  7. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 07 Mar 2014 Link to this post

    Hi Slav,

    Yes, I use .225. In fact, the issue appeared when I upgraded from .717.

    I could not reproduce. My app is using routing and my own http module. I did create a new project and added some dll's from my app, but still I could not reproduce.
    Maybe your development can think of a cause?

    in the mean time, I added code to refresh the image/code after every postback. I have 2 solutions:

    1.Dim str_Script As String = " __doPostBack('" & RadCaptcha1.ClientID & "$CaptchaLinkButton',''); "  ' RadCaptcha1$CaptchaLinkButton
    2.ClientScript.RegisterClientScriptBlock(Me.GetType(), "CaptchaFixFirst", str_Script, True)
    3. 
    4.str_Script = "<script type=""text/javascript"">" & str_Script & "</script>"
    5.RadCaptcha1.Controls.Add(New LiteralControl(str_Script))


    Erik
    s
  8. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 11 Mar 2014 Link to this post

    Hi Erik,

    Could you please clarify what code refresh means? The RadCaptcha is validated on postback, which is also initiated when you perform a refresh, according to the code snippet in the previous post, however the result of these two operations appears to be different.

    I would suggest ensuring that your page is indeed not AJAX enabled, because the problem you described could happen if you have a page with AJAX, in which the captcha is not updated by the partial postback. In this case a new captcha code is generated without updating the image and if you try validating, you will not be successful. If this is the case you can try setting the property of the captcha CaptchaImage-PersistCodeDuringAjax to true.

    If isolating the problem is not possible, please send a code snippet that shows the logic, which is executed in your login page. There are things that are not quite clear, for example in your first post you mentioned that the captcha is not initially hidden, however it is then added that you show it only when a wrong password is entered.

    Regards,
    Slav
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  9. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 12 Mar 2014 in reply to Slav Link to this post

    Hello Slav,

    To be clear: I did state I hide it initially, and I did state I'm not using AJAX:
      "I have a simple login form, no AJAX panels or stuff, that hides the RadCaptcha initially. When you enter a wrong password, the RadCaptcha is shown and the validation happans server side." 

    I will look at the proerty "CaptchaImage-PersistCodeDuringAjax" later. I'm a bit busy now... ;-) but I will come back at it later.

    Erik
  10. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 14 Mar 2014 Link to this post

    Hi Erik,

    If no partial postbacks are used in your page then configuring the property PersistCodeDuringAjax most probably will not affect the encountered behavior.

    When you get back to this scenario, please clarify what is the difference between performing a postback and refreshing the code and if possible send a sample that shows your implementation.

    I am looking forward to your update on the case.

    Regards,
    Slav
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017