Validating the Recaptcha with CreateUserWizard in Asp.Net?

94 views
Skip to first unread message

LuizItatiba

unread,
Jan 24, 2009, 12:02:39 AM1/24/09
to reCAPTCHA
I'm using Recaptcha with CreateUserWizard in Asp.Net both in SSL mode,
https, but also in normal mode of that domain registered with
Recaptcha and the public key and private keys added

and I'm using it to my createuzer wizard implemented in my ASP.NET
AJAX web application in my ENABLED VisualStudio2005 below the source
and codigo.cs

Source - page novo.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master"
AutoEventWireup="true" CodeBehind="Novo.aspx.cs"
Inherits="MeuWebProfileGenerator.Novo" Title="Untitled Page" %>

<%@ Register Assembly="Recaptcha" Namespace="Recaptcha"
TagPrefix="recaptcha" %>



<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server"><asp:CreateUserWizard ID="CreateUserWizard1"
runat="server" BackColor="#34011F" BorderColor="#B5C7DE"
BorderStyle="Solid" BorderWidth="1px"
ContinueDestinationPageUrl="~/Repeater.aspx"
Font-Names="Verdana" Font-Size="0.8em"
OnContinueButtonClick="CreateUserWizard1_ContinueButtonClick"
ForeColor="White" OnActiveStepChanged="captchaValidate">
<SideBarStyle BackColor="#507CD1" Font-Size="0.9em"
VerticalAlign="Top" />
<SideBarButtonStyle BackColor="#507CD1" Font-Names="Verdana"
ForeColor="White" />
<ContinueButtonStyle BackColor="White" BorderColor="#507CD1"
BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284E98" />
<NavigationButtonStyle BackColor="White" BorderColor="#507CD1"
BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284E98" />
<HeaderStyle BackColor="#284E98" BorderColor="#EFF3FB"
BorderStyle="Solid" BorderWidth="2px"
Font-Bold="True" Font-Size="0.9em" ForeColor="White"
HorizontalAlign="Center" />
<CreateUserButtonStyle BackColor="White" BorderColor="#507CD1"
BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284E98" />
<TitleTextStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<StepStyle Font-Size="0.8em" />
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1"
runat="server">
<ContentTemplate>
<table border="0" style="font-size: 100%; font-
family: Verdana">
<tr>
<td align="center" colspan="2" style="font-
weight: bold; color: white; background-color: #507cd1">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel"
runat="server" AssociatedControlID="UserName">User Name:</asp:Label></
td>
<td>
<asp:TextBox ID="UserName"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is
required." ToolTip="User Name is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel"
runat="server" AssociatedControlID="Password">Password:</asp:Label></
td>
<td>
<asp:TextBox ID="Password"
runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator
ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is
required." ToolTip="Password is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="ConfirmPasswordLabel"
runat="server" AssociatedControlID="ConfirmPassword">Confirm
Password:</asp:Label></td>
<td>
<asp:TextBox ID="ConfirmPassword"
runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator
ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPassword"
ErrorMessage="Confirm Password is
required." ToolTip="Confirm Password is required."

ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="EmailLabel"
runat="server" AssociatedControlID="Email">E-mail:</asp:Label></td>
<td>
<asp:TextBox ID="Email"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="E-mail is required."
ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</
asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="QuestionLabel"
runat="server" AssociatedControlID="Question">Security Question:</
asp:Label></td>
<td>
<asp:TextBox ID="Question"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="QuestionRequired" runat="server" ControlToValidate="Question"
ErrorMessage="Security question is
required." ToolTip="Security question is required."

ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="AnswerLabel"
runat="server" AssociatedControlID="Answer">Security Answer:</
asp:Label></td>
<td>
<asp:TextBox ID="Answer"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="AnswerRequired" runat="server" ControlToValidate="Answer"
ErrorMessage="Security answer is
required." ToolTip="Security answer is required."

ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<recaptcha:RecaptchaControl
ID="RecaptchaControl1" runat="server" PublicKey="mykey"
PrivateKey="mykey"/>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator
ID="PasswordCompare" runat="server" ControlToCompare="Password"

ControlToValidate="ConfirmPassword" Display="Dynamic"
ErrorMessage="The Password and Confirmation Password must match."

ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2"
style="color: red">
<asp:Literal ID="ErrorMessage"
runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:WizardStep ID="WizardStep1" runat="server"
Title="Dados para Contato">
<table>
<tr>
<td colspan="2" style="background-color:
#ccffff; text-align: center">
<asp:Label ID="Label1" runat="server"
Text="Dados para Contato"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label2" runat="server"
Text="Endere&#231;o:"></asp:Label>
</td>
<td style="width: 100px">
<asp:TextBox ID="txtEnd" runat="server"></
asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label3" runat="server"
Text="Telefone:"></asp:Label>
</td>
<td style="width: 100px">
<asp:TextBox ID="txtTel" runat="server"></
asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="chkCrianca"
runat="server" Text="Tenho Crian&#231;a em casa" />
</td>
</tr>
</table>
</asp:WizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1"
runat="server">
<ContentTemplate>
<table border="0" style="font-size: 100%; font-
family: Verdana">
<tr>
<td align="center" colspan="2" style="font-
weight: bold; color: white; background-color: #507cd1">
Complete</td>
</tr>
<tr>
<td>
Your account has been successfully
created.</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="ContinueButton"
runat="server" BackColor="White" BorderColor="#507CD1"
BorderStyle="Solid"
BorderWidth="1px" CausesValidation="False" CommandName="Continue"
Font-Names="Verdana"
ForeColor="#284E98" Text="Continue"
ValidationGroup="CreateUserWizard1" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</asp:Content>

code-behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Recaptcha;

namespace MeuWebProfileGenerator
{
public partial class Novo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void CreateUserWizard1_ContinueButtonClick(object
sender, EventArgs e)
{
//Pesquisa/Recupera dados dos IDs de Controles do
CreateUserWizard
CheckBox chk = (CheckBox)CreateUserWizard1.FindControl
("chkCrianca");
TextBox txtTel = (TextBox)CreateUserWizard1.FindControl
("txtTel");
TextBox txtEnd = (TextBox)CreateUserWizard1.FindControl
("txtEnd");

//Cria o Profile baseado na Class MyWebProfile do
WebProfileGenerator3.1
string username;
username = CreateUserWizard1.UserName;
//Maneira Errada com o WebProfileGenerator
//WebProfile prof = WebProfile.Create(username);

//Maneira Correta com o WebProfile Generator
WebProfile prof = new WebProfile().GetProfile(username);
//Repassa os dados inseridos nos controles
//para as propriedades(campos) dos perfis
//do profile criado
prof.Crianca = chk.Checked;
prof.Endereco = txtEnd.Text;
prof.Telefone = txtTel.Text;

//chama o método Save para salvar
//os perfis de meu usuário na Base
//AspNetDb ou do ProfileProvider criada
prof.Save();


}
private WebProfile Profile
{
get { return new WebProfile(Context.Profile); }
}

protected void captchaValidate(object sender, EventArgs e)
{
RecaptchaControl myControl = new RecaptchaControl();

CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl
("RecaptchaControl1");
myControl.Validate();
if (myControl.IsValid)
{
myControl.SkipRecaptcha = true;
myControl.Visible = false;
}
}



}
}

But even then typing the two words Recaptcha both in the correct way
of increasing performance as the host site in my links published both
in SSL mode (https: / /) and in order http://

the Recaptcha not valid and does not go to the next step in the
CreateUserWizard

How to fix this

If someone can help me now thank you

Translated from Portuguese into English by Google

Dan Kimble

unread,
Jan 29, 2009, 10:06:14 PM1/29/09
to reCAPTCHA
After fighting with this for several days myself, I finally found the
answer on another web site.

To make reCaptcha work with the CreateUserWizard you need to:

1. Download the source code for the reCaptcha ASP.NET control.
2. Modify the code and recompile.
3. Use the new DLL in your ASP.NET project.
4. Add code to the OnCreatingUser event of the CreateUserWizard.

On this site you can find the complete details:
http://www.codeverge.net/ng.asp-net-forum.security/create-user-wizard-with-captcha

Dan


On Jan 24, 12:02 am, LuizItatiba <divulguesi...@hotmail.com> wrote:
> I'm usingRecaptchawithCreateUserWizardin Asp.Net both in SSL mode,
> https, but also in normal mode of that domain registered withRecaptchaand the public key and private keys added
>
> and I'm using it to my createuzer wizard implemented in my ASP.NET
> AJAX web application in my ENABLED VisualStudio2005 below the source
> and codigo.cs
>
...............
>
> But even then typing the two wordsRecaptchaboth in the correct way
> of increasing performance as the host site in my links published both
> in SSL mode (https: / /) and in order http://
>
> theRecaptchanot valid and does not go to the next step in theCreateUserWizard

Agile Consulting

unread,
Feb 7, 2009, 3:12:28 AM2/7/09
to reCAPTCHA
Explain ADO and RDO

Paul Herring

unread,
Feb 7, 2009, 4:52:37 PM2/7/09
to reca...@googlegroups.com
On Sat, Feb 7, 2009 at 8:12 AM, Agile Consulting
<agile.s...@gmail.com> wrote:
>
> Explain ADO and RDO

I'm not sure that using a(n unrelated) group as a search engine is the
quickest way of answering your question.

There appears to be a wealth of information if you type [ado rdo
difference] into Google for example.


--
PJH

http://shabbleland.myminicity.com

Message has been deleted
Message has been deleted

ersking

unread,
Feb 7, 2009, 5:37:42 PM2/7/09
to reCAPTCHA
Paul,

Please be kind to folk who are not as knowledgeable as you are.

Agile Consulting just needed a quick link :

Difference between ADO and RDO ?

For answer, then click : http://tinyurl.com/b3j379

Best wishes,

ersking

--------------------------------------------------------------------------------------------



On Feb 7, 9:52 pm, Paul Herring <pauljherr...@gmail.com> wrote:
> On Sat, Feb 7, 2009 at 8:12 AM, Agile Consulting
>

Paul Herring

unread,
Feb 8, 2009, 7:37:20 AM2/8/09
to reca...@googlegroups.com
On Sat, Feb 7, 2009 at 10:31 PM, gm...@erskine-uk.net <ers...@gmail.com> wrote:
> Paul,
>
> Please be kind to folk who are not as knowledgeable as you are.

I was. For example I didn't provide a link to
<http://tinyurl.com/agtcmr>, nor did I even think of mentioning
<http://tinyurl.com/anel>

> Agile Consulting just needed a link :

Oh - you mean I should have provided the links above? Even though the
question they asked had nothing to do with recaptcha whatsoever?


--
PJH

http://shabbleland.myminicity.com

Charles Sweeney

unread,
Feb 8, 2009, 8:55:16 AM2/8/09
to reCAPTCHA
ersking wrote:

> Paul,
>
> Please be kind to folk who are not as knowledgeable as you are.
>
> Agile Consulting just needed a quick link :
>
> Difference between ADO and RDO ?
>
> For answer, then click : http://tinyurl.com/b3j379

I would normally agree with your sentiments, ersking, particularly in
a group like this where the usual activity is from tumbleweed blowing
across it. Posters should be made welcome and should not be given
smart-arse replies that take as long to type as a helpful reply.

In this case, "Agile Consulting" has made the exact same post, and
changed the subject line, in at least nine other groups (see his
profile) so is in fact being a prat and deserves all he gets.

--
Charles Sweeney
http://FormToEmail.com
PHP mail script with reCAPTCHA

Agile Consulting

unread,
Feb 9, 2009, 1:20:10 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 2:12:07 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 2:29:45 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 2:46:47 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 3:25:33 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Paul Herring

unread,
Feb 9, 2009, 4:13:55 AM2/9/09
to reca...@googlegroups.com
On Mon, Feb 9, 2009 at 6:20 AM, Agile Consulting
<agile.s...@gmail.com> wrote:
>
> Explain ADO and RDO

Haven't we been through this before?


--
PJH

http://shabbleland.myminicity.com

Agile Consulting

unread,
Feb 9, 2009, 5:16:54 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 5:45:17 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 5:50:45 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 5:58:05 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 6:13:14 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 7:09:20 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 7:22:30 AM2/9/09
to reCAPTCHA
Explain ADO and RDO

Agile Consulting

unread,
Feb 9, 2009, 7:30:50 AM2/9/09
to reCAPTCHA
Explain ADO and RDO
Reply all
Reply to author
Forward
0 new messages