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?
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?
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).
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).
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.
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 )
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.
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)
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.
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.
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)
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.
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.
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.
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
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
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
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
Well the usercontrol one will become obsolete since some things aren't possible with it (like the custom validation)
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
Will give it a go this week, guess only option is to include a captcha by default so will look into that
I'm attempting something similar, based on jquery form validate, let me know if you get a solution.
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
Yup looking at it today/tomorrow so I'll let you know how I get allong
Awesome cheers Tim :-)
Comment author was deleted
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/
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
True, guess we'll bundle it with Contour then as a new fieldtype since it needs some core addons
Fab Tim, it makes sense to include it as a standard fieldtype
Many thanks
Martin
Comment author was deleted
Success got recaptcha working so should have a build you can test/use ready later today :)
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
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 )
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
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
In the latest 3.0.7 WIP build it also works for the usercontrol macro
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
Hmm that's strange since that didn't change, could you try updating that assembly again and touching the web.config
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
Ok then the assembly might not be needed, try seeing what it does when it isn't there
Thanks Tim, been in a meeting all day, will try this out first thing / or maybe if my wife lets me - this evening :-)
Hi Tim
Somethings definitely gona tits up with your references, I've reverted back to 3.0.6 and all is good again.
Martin
Hi Tim
I was able to redirect the binding error by adding this to my web.config...
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
Ok thanks for the details I'll check why this happens
Comment author was deleted
Also get it on a fresh install, looking into it but if the workaround works for now that's great :)
Comment author was deleted
You can do that in the contour config \Umbraco\plugins\umbracoContour\UmbracoContour.config (the recaptcha keys)
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
System.Web.Mvc error has been fixed in the latest nightly build of 3.0.7 WIP
Comment author was deleted
@martin regarding the config file, well at the time we made the decistion to keep everything in the \Umbraco\plugins\umbracoContour\ folder
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
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
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.
Please ignore that last question, I have it sorted now, overlooked the form.cshtml
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
Ok you have a custom theme, don't think that is supported at the moment but will take a look at what is needed
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)
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.
hi mike , have you got a specific error?
Comment author was deleted
Hey Mike,
Are you using the built in recaptcha field?
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.
is the captcha failing? do you have the recaptcha dll installed?
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
Ok Mike are you using the usercontrol or the razor macro to insert your contour forms?
Razor macro
Comment author was deleted
Ok will have a look and try to reproduce, will report back in a couple of mins :)
Comment author was deleted
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?
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
Ok if it works in preview there must be something wrong with the template setup but let's see what you find :)
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
Hmm that's strange, and did you perform any updates on your templates since it started working?
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
Nope rte or template that shouldn't matter
I give up... lol maybe I was not sitting in the right place or the planets were misaligned or something.
Comment author was deleted
Yeah must have been a full moon
is working on a reply...