Captcha only validates the second time

8 posts, 1 answers
  1. Alexander
    Alexander avatar
    2 posts
    Member since:
    Jan 2013

    Posted 23 Jan 2014 Link to this post

    I have been searching around about this issue and I found some related information but I just can't seem to get Telerik's Captcha to work properly.

    No matter what I do, without fail the captcha will only validate on the second try. On the first try, it fails, and the second time it always works.

    I do not use a web farm or cluster, it's just one server. I've tried most things that are documented, like changing the ImageStorageLocation to Session. The behavior is the same either way.

    Anyone have any ideas?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Jan 2014 Link to this post

    Hi Alexander,

    Unfortunately I couldn't replicate the issue at my end. Please have a look into the following code snippet which works fine at my end. Let me know the given code is working for you or not.

    ASPX:
    <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="code entered is not valid."
        ValidationGroup="Group">
    </telerik:RadCaptcha>
    <asp:Button ID="btnVerify" runat="server" Text="Submit Page" Width="150px" ValidationGroup="Group"
        OnClick="btnVerify_Click">
    </asp:Button>
     
    C#:
    protected void btnVerify_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            Response.Write("<script>alert('Succes');</script>");
        }
    }

    Please provide your full code if it doesn't help.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alexander
    Alexander avatar
    2 posts
    Member since:
    Jan 2013

    Posted 24 Jan 2014 Link to this post

    Thanks for your help. I'm going to try to set this up in a blank project and see if the issue persists. I may attach my code in a while if I don't make any progress.
  5. Answer
    Vessy
    Admin
    Vessy avatar
    1382 posts

    Posted 24 Jan 2014 Link to this post

    Hi Alexander,

    I have just answered your support ticket on the subect - for convenience I am pasting my answer here as well:

    Most probably the experienced error is connected with the way the async PostBack is triggered. Basically the Captcha updates its code on every page life cycle, even if its element is not updated. The image, on another side is changed only then the Captcha is updated. This is why I would suggest you to try setting the Captcha's image PersistCodeDuringAjax property to true and see whether the problem still persist:
    <telerik:RadCaptcha ID="RadCaptcha1" ValidationGroup="Submit" runat="server" ErrorMessage="Text entered below is not valid" ForeColor="Red" EnableRefreshImage="True">
        <CaptchaImage PersistCodeDuringAjax="true" />
    </telerik:RadCaptcha>


    Kind regards,
    Veselina Raykova
    Telerik
    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 the blog feed now.
  6. rightincode
    rightincode avatar
    2 posts
    Member since:
    Feb 2014

    Posted 24 Mar 2014 Link to this post

    I can consistently reproduce this problem on a simple form (no ajax postbacks/panels, etc.) with a validationgroup.  In the validationgroup I have a radtextbox, requiredfieldvalidator, captcha, and radbutton.  If I remove the validationgroup, the captcha is valid when I enter the correct input on the first attempt.  With the validationgroup, the captcha is invalid on the first attempt with the correct input and valid only on the second attempt with the correct input.

    I'm using version 2014.1.225.45 and .net 4.5.

    Any additional suggestions on correcting this issue would be helpful.
  7. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 27 Mar 2014 Link to this post

    Hello Richard,

    I tried to reproduce the problem by creating a sample according to the description your provided, but to no avail. You can find the test sample attached to this post. Please check it and let me know what am I missing and how it should be modified for the issue to occur. The behavior that is experienced on my end is shown in the following screen capture: http://screencast.com/t/hBIUlLY3s

    You can also edit that page in order to replicate your setup so that I can inspect the problem locally and suggest a solution, if there is such.

    Regards,
    Slav
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  8. rightincode
    rightincode avatar
    2 posts
    Member since:
    Feb 2014

    Posted 29 Apr 2014 in reply to Slav Link to this post

    Thanks Slav!

    We were able to figure out the problem.
  9. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 30 Apr 2014 Link to this post

    Hi Richard,

    I am very happy that you succeeded in resolving the problem.

    Will it be possible to send your configuration of the RadCaptcha, as well as information how you fixed the problem, so that we can research whether it originated from the captcha?

    Regards,
    Slav
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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