Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 02, 2013 @ 17:58
    Martin Griffiths
    0

    Contour Contrib Captcha CodeFirst

    Hi Tim

    I've had a lot of success with your CodeFirst forms but I'm now struggling with implementing a Captcha using the Contour.Contrib library and your examples in http://www.nibble.be/?p=220

    Firstly in the documentation it says NOT to set the field to mandatory otherwise it simply fails to pass the validation. You might want to ammend this on your blog.

    I'm using the Razor macro to insert the contour form and therefore had to create my own View. This works fine and the Captcha displays as expected.

    The problem I have now is that it passes through the Validate() and Submit() meothods regardless of whether I input the correct Captcha text or not. Which is not much use! (or protection).

    After a little reading of the Captcha APIs for .net it would appear that the response is handled by a Page.IsValid. Of course in @razor things handled are somewhat differently.

    Am I doing something wrong or is there another bug lurking?

    Happy New Year BTW!

    Kind regards

    Martin

  • Comment author was deleted

    Jan 03, 2013 @ 09:07

    Hi Martin, 

    The recaptcha is a difficult control since it also requires updated to the controller and that isn't exposed 

    Explained in this example http://devlicio.us/blogs/derik_whittaker/archive/2008/12/02/using-recaptcha-with-asp-net-mvc.aspx

    I'll see what I can do about that....

    But what is good to know is that the razor macro adds anti spam by default (honeypot technique)

    Regards,

    Tim

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 03, 2013 @ 10:53
    Martin Griffiths
    0

    Hi Tim

    I read a little into the honeypot technique and it's a simple, yet effective idea.

    Unfortunately I dont know if it will be enough to keep my employers happy though!

    Let me know if you manage to get the Captcha working in MVC.

    Many thanks

    Martin

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 03, 2013 @ 11:34
    Martin Griffiths
    0

    Hi Tim

    One extra thought....Is there any way you can get the Validate() method working properly with the usercontrol? Would it not make sense to offer full functionality in both methods?

    Martin

  • Comment author was deleted

    Jan 03, 2013 @ 13:55

    Well the usercontrol one will become obsolete since some things aren't possible with it (like the custom validation)

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 14, 2013 @ 11:42
    Martin Griffiths
    0

    Hi Tim

    I was wondering if you could give me an idea of when you can take a look at the Captcha/MVC view issues?

    Kind regards

    Martin

  • Comment author was deleted

    Jan 14, 2013 @ 13:10

    Will give it a go this week, guess only option is to include a captcha by default so will look into that

  • Nick Renny 31 posts 63 karma points
    Jan 15, 2013 @ 20:21
    Nick Renny
    0

    I'm attempting something similar, based on jquery form validate, let me know if you get a solution.

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 10:33
    Martin Griffiths
    0

    Hi Nick

    Contour has a bunch of extension methods called "contour.contrib" which needs some extra work to get the Captcha extension working with MVC partial views (Razor macro).

    http://our.umbraco.org/projects/developer-tools/contour-contrib

    This is what I've asked Tim to fix.

    Martin

  • Comment author was deleted

    Jan 16, 2013 @ 10:36

    Yup looking at it today/tomorrow so I'll let you know how I get allong

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 10:37
    Martin Griffiths
    0

    Awesome cheers Tim :-)

  • Comment author was deleted

    Jan 16, 2013 @ 11:05

    Think this approach should work as a plugin (so no need to customize the source), giving it a try now http://www.stefanprodan.eu/2012/01/user-friendly-captcha-for-asp-net-mvc/

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 11:08
    Martin Griffiths
    0

    Hi Tim

    It's a nice idea, but ReCaptcha is based on a mountain of hacking research, offers accessibility options and is considered a solid and dependable solution (its now owned by Google).

    Is there any chance you can stick with it?

    Martin

  • Comment author was deleted

    Jan 16, 2013 @ 11:10

    True, guess we'll bundle it with Contour then as a new fieldtype since it needs some core addons

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 11:12
    Martin Griffiths
    0

    Fab Tim, it makes sense to include it as a standard fieldtype

    Many thanks

    Martin

  • Comment author was deleted

    Jan 16, 2013 @ 12:10

    Success got recaptcha working so should have a build you can test/use ready later today :) 

  • Nick Renny 31 posts 63 karma points
    Jan 16, 2013 @ 12:45
    Nick Renny
    0

    That is great news Tim, I am actually trying to get it to work with contrib and restContour. I have the form hand built in a razor template, but it's occured to me that that won't work too easily with reCaptcha, I'll need to drop the form and style it straight into the razor template? can I use a razor based template for contour, I can see that there is a razor renderer, but I can only access it in a master page template? I'm running Umbraco 4.11.2 currently.

     

  • Comment author was deleted

    Jan 16, 2013 @ 13:17

    Hey Nick,

    With the razor render that is new from version 3 you can have full control over the form markup, by updating some views that can be found in the \umbraco\plugins\umbracoContour\Views directory (check the readme in \umbraco\plugins\umbracoContour\Views\Forms )

  • sun 403 posts 395 karma points
    Jan 16, 2013 @ 13:30
    sun
    0

    I suggest that you should include a simple captcha field. It can only be set only to show number or alphabet, and can set how many characters will be shown. 

    Google recaptcha is too diffcult to use for many end viewers who are not using English.

    number type captcha and alphabet is suitable for whole world users.

    The following project may be useful to you.

    http://captchamvc.codeplex.com/

  • Comment author was deleted

    Jan 16, 2013 @ 13:39

    If you use 3.0.7 WIP you can see a recaptcha fieldtype that currently only works with the razor macro

    Example here: http://www.screenr.com/wGR7

    Update for the usercontrol one also coming up

  • Comment author was deleted

    Jan 16, 2013 @ 15:04

    In the latest 3.0.7 WIP build it also works for the usercontrol macro

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 16:02
    Martin Griffiths
    0

    Hi Tim

    Im getting this after upgrading

    Server Error in '/' Application.


    Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

  • Comment author was deleted

    Jan 16, 2013 @ 16:08

    Hmm that's strange since that didn't change, could you try updating that assembly again and touching the web.config

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 16:09
    Martin Griffiths
    0

    I think it might be because I recently loaded up VS2012. Version mismatch somehow, but the files are in the BIN.

  • Comment author was deleted

    Jan 16, 2013 @ 16:13

    Ok then the assembly might not be needed, try seeing what it does when it isn't there

  • Nick Renny 31 posts 63 karma points
    Jan 16, 2013 @ 16:28
    Nick Renny
    0

    Thanks Tim, been in a meeting all day, will try this out first thing / or maybe if my wife lets me - this evening :-)

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 16:50
    Martin Griffiths
    0

    Hi Tim

    Somethings definitely gona tits up with your references, I've reverted back to 3.0.6 and all is good again.

    Martin

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 17:04
    Martin Griffiths
    0

    Hi Tim

    I was able to redirect the binding error by adding this to my web.config...

     

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/>
          </dependentAssembly>
        </assemblyBinding>
  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 17:10
    Martin Griffiths
    0

    Hi Tim

    You've not added public/private keys to additional settings which locks down the reCaptcha to your domain, this needs to be passed into the view.

    Can you add this?

    Martin

  • Comment author was deleted

    Jan 16, 2013 @ 17:10

    Ok thanks for the details I'll check why this happens

  • Comment author was deleted

    Jan 16, 2013 @ 17:22

    Also get it on a fresh install, looking into it but if the workaround works for now that's great :)

  • Comment author was deleted

    Jan 16, 2013 @ 17:28

    You can do that in the contour config \Umbraco\plugins\umbracoContour\UmbracoContour.config (the recaptcha keys)

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 16, 2013 @ 17:31
    Martin Griffiths
    0

    Hi Tim

    Ahh! that makes sense! Superb!

    Is there any reason why the umbracoContour.config isnt in the newer configs folder in the root of Umbraco?

  • Comment author was deleted

    Jan 17, 2013 @ 11:15

    System.Web.Mvc error has been fixed in the latest nightly build of 3.0.7 WIP

  • Comment author was deleted

    Jan 17, 2013 @ 11:16

    @martin regarding the config file, well at the time we made the decistion to keep everything in the \Umbraco\plugins\umbracoContour\ folder

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 17, 2013 @ 11:33
    Martin Griffiths
    0

    Hi Tim

    Thanks for the info, i'll download the new version today and test out the ReCaptcha.

    I was wondering if you could answer a side question for me?

    We've noticed in version 4.11.3.1 that the umbraco.dll hasnt been signed, but all the others are signed. This is causing issues using in one of our projects which uses signed librarires, it's seems that communication between signed and un-signed libraries can cause issues in VS.

    Do you know why the umbraco.dll isnt signed? Maybe it's just a mistake, but thought i'd ask just in-case you had knowledge on this.

    Martin

  • Comment author was deleted

    Jan 17, 2013 @ 11:38

    Nope sorry don't have an idea, better ask on http://our.umbraco.org/forum/core/general or if you consider this a bug report it here http://issues.umbraco.org/issues/U4

  • Nick Renny 31 posts 63 karma points
    Jan 17, 2013 @ 18:28
    Nick Renny
    0

    I've got the forms working in a standard sense, I want to be able to render the form and the reCaptcha via mvc, from within a partial like this:

     

                                        <formaction=""method="post"id="form-@(ViewBag.vote_form_guid)"name="qaForm">

                                          <p>Type the two words below:p>

                                          <img src="@Url.Content("~/img/captchaTest.jpg")" />

                                          <inputtype="text"id="captchatest"name="captchatest"class="nw-text-box"/>

                                          <label for="txtName">enter your namelabel>

                                          <inputtype="text"id="txtName"name="txtName"class="nw-text-box"/>

                                          <label for="txtEmail">enter your email addresslabel>

                                          <inputtype="text"id="txtEmail"name="txtEmail"class="nw-text-box"/>

                                          <inputtype="submit"class="nw-capture-submit-button"value=""src="@Url.Content("~/img/place-your-vote.jpg")"/>

    @*                                      *@

                                          <div class="errorList">div>

                                        form>

     

    within that form i need to render the reCaptcha widget, and post it back to contour - is this possible?

     

    I should say I am doing it like this because I want to post back using ajax, so I want to ensure the submit doesn't refresh the page, but I also need to ensure that the captcha image can be validated correctly, as far as I understand contour is using the recaptcha.dll to add the widget, and the image is generated by google. 

  • Nick Renny 31 posts 63 karma points
    Jan 17, 2013 @ 20:31
    Nick Renny
    0

    Please ignore that last question, I have it sorted now, overlooked the form.cshtml

  • Nick Renny 31 posts 63 karma points
    Jan 18, 2013 @ 14:55
    Nick Renny
    0

    Hi Tim, I've got a quick question, the custom theme, doesn't seem to override the themes setting, I think you may have overlooked it?

  • Comment author was deleted

    Jan 18, 2013 @ 14:57

    Ok you have a custom theme, don't think that is supported at the moment but will take a look at what is needed

  • Nick Renny 31 posts 63 karma points
    Jan 18, 2013 @ 15:03
    Nick Renny
    0

    I think that it might just be no displaying the regular form, as you have to include your own captcha div, also, to submit the form with captcha via ajax to contour what fields does the recaptcha expect, I have assumed recaptcha_challenge_field, recaptcha_response_field, (I'm using restContour to submit the form)

  • MikeD 92 posts 112 karma points
    Jul 15, 2013 @ 20:45
    MikeD
    0

    is there some documentation somewhere explaining how to implement the ReCaptcha field?  I have it added to my form but something is not working because it will not submit.  I am running Contour 3.0.14.

  • Nick Renny 31 posts 63 karma points
    Jul 16, 2013 @ 08:17
    Nick Renny
    0

    hi mike , have you got a specific error?

  • Comment author was deleted

    Jul 16, 2013 @ 10:13

    Hey Mike,

    Are you using the built in recaptcha field?

  • MikeD 92 posts 112 karma points
    Jul 16, 2013 @ 13:47
    MikeD
    0

    Good morning Nick and Tim,

    There are no errors, and yes it is the built in recaptcha field.  I add it to my form, save, go to the public page, I see the filed, enter in the text and click submit.  The form reloads with all my data still in the form fileds.

    I have 2 sites being attacked by spambots, I really gotta get this figured out asap.  Thanks for the quick replies.

  • Nick Renny 31 posts 63 karma points
    Jul 16, 2013 @ 13:52
    Nick Renny
    0

    is the captcha failing? do you have the recaptcha dll installed?

  • MikeD 92 posts 112 karma points
    Jul 16, 2013 @ 14:03
    MikeD
    0

    I don't know about the dll, I have not installed anything but Contour.  That's why I was asking about some documentation to be sure I didn't miss anything.  Even if someone could post the steps here... I know I am missing something, I just don't know what.

  • Comment author was deleted

    Jul 16, 2013 @ 14:03

    Ok Mike are you using the usercontrol or the razor macro to insert your contour forms?

  • MikeD 92 posts 112 karma points
    Jul 16, 2013 @ 14:06
    MikeD
    0

    Razor macro

  • Comment author was deleted

    Jul 16, 2013 @ 14:08

    Ok will have a look and try to reproduce, will report back in a couple of mins :)

  • Comment author was deleted

    Jul 16, 2013 @ 14:10

    Just tried and it worked fine so hard to tell what is going wrong

    If you preview the form in the Contour section does it also fail at that point?

  • MikeD 92 posts 112 karma points
    Jul 16, 2013 @ 14:28
    MikeD
    0

    I will test that when I get to the office in about an hour.

    FYI, whoever is in charge of these forums... you cannot post from an iPhone.  

  • Comment author was deleted

    Jul 16, 2013 @ 14:36

    Ok if it works in preview there must be something wrong with the template setup but let's see what you find :)

  • MikeD 92 posts 112 karma points
    Jul 16, 2013 @ 15:43
    MikeD
    0

    Yes, it worked in preview, then I tested the page again and this time it worked.  How odd.... I tested several times yesterday and it did not post.

    Thanks again for the rapid responses, it's great to know help is just a message away!

  • Comment author was deleted

    Jul 16, 2013 @ 15:45

    Hmm that's strange, and did you perform any updates on your templates since it started working?

  • MikeD 92 posts 112 karma points
    Jul 16, 2013 @ 15:48
    MikeD
    0

    I have not done anything... that's why it is so weird.  lol  

    If it helps, I am inserting the macro into a RTE box.  Is there a better way to do it?

  • Comment author was deleted

    Jul 16, 2013 @ 15:48

    Nope rte or template that shouldn't matter

  • MikeD 92 posts 112 karma points
    Jul 16, 2013 @ 15:53
    MikeD
    0

    I give up... lol  maybe I was not sitting in the right place or the planets were misaligned or something.

  • Comment author was deleted

    Jul 16, 2013 @ 15:58

    Yeah must have been a full moon

Please Sign in or register to post replies

Write your reply to:

Draft