Solved

RECAPTHA WITH VISUAL STUDIO LOGIN FORM

Posted on 2011-02-15
7
501 Views
Last Modified: 2012-06-27
I am using asp.net 4 with visual studio.  I am just using the simple login form that comes with the website install.  I want to use recaptha with it.  I downloaded and did everything they ask for to install and the recaptha picture looks good on the login form but it accepts any word I put in.  My guess is that it is not validating it because of my code.  I have included my code to the login.asp form and any help would be appreciated.
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

<%@ Page Title="Log In" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeFile="Login.aspx.vb" Inherits="Account_Login" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Log In
    </h2>
    <p>
        Please enter your username and password.
        <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account.
    </p>
    <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
        <LayoutTemplate>
            <span class="failureNotification">
                <asp:Literal ID="FailureText" runat="server"></asp:Literal>
                 <recaptcha:RecaptchaControl     ID="recaptcha"     runat="server"     PublicKey="6LcFuL0SAAAAAMRPUHEkLicXVQwGNN-yywkvXSDN"     PrivateKey="6LcFuL0SAAAAAPeam9siNDf0Mc3i5T02hc5j_EKc"     />
            </span>
            <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" 
                 ValidationGroup="LoginUserValidationGroup"/>
            <div class="accountInfo">
                <fieldset class="login">
                    <legend>Account Information</legend>
                    <p>
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
                        <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" 
                             CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." 
                             ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                        <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
                             CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." 
                             ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:CheckBox ID="RememberMe" runat="server"/>
                        <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
                    </p>
                </fieldset>
                <p class="submitButton">
                    <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/>
                    <recaptcha:RecaptchaControl     ID="RecaptchaControl1"     runat="server"     PublicKey="6LcFuL0SAAAAAMRPUHEkLicXVQwGNN-yywkvXSDN"     PrivateKey="6LcFuL0SAAAAAPeam9siNDf0Mc3i5T02hc5j_EKc"     />
              
                </p>
            </div>
        </LayoutTemplate>
    </asp:Login>
    
    
</asp:Content>

Open in new window

0
Comment
Question by:bidgadget
  • 4
  • 3
7 Comments
 
LVL 27

Expert Comment

by:BigRat
ID: 34905479
According to http://code.google.com/intl/de/apis/recaptcha/docs/aspnet.html there should be a FORM on your page, which I don't  see. Secondly there are TWO recaptura controls on the page?

I'd stick exactly to the example given on the web site, since it seems that the control expects to have things it's way.
0
 

Author Comment

by:bidgadget
ID: 34907128
Thank you for respoinding.  I tried to put a form tag but I get a error message saying a form can have only one form tag.  Although I do not see another.  In your link you sent I am not sure how to complete step 3.

Thank you
0
 
LVL 27

Accepted Solution

by:
BigRat earned 500 total points
ID: 34907340
Well it is probably the case that the asp:Login produces the actual HTML form tag, but since this is not present at server time the captura control cannot link to it (presumably, since I have no idea how it is actually inplemented).

I see that the control has NOT been updated for .NET 2 which you are using, and subsequently you'll have to either modify the control or add a custom validator. This web site shows up the issues :-

http://stackoverflow.com/questions/231344/how-to-make-recaptcha-work-with-a-validationgroup-in-asp-net-captcha

It seems that adding a custom validator is the best way to go.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:bidgadget
ID: 34907440
I am using asp.net 4

Looks like this is not the right idea for me for multi factor authenication.   Would you recommend any other captha programs?
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34909174
>>I am using asp.net 4

The control is certainly not ASP 4 compatible. But I don't see why adding a custom validation is a problem? Here is the example :-

http://www.15seconds.com/issue/050216.htm
0
 

Author Comment

by:bidgadget
ID: 34909250
we have to have dual authenication on our website.  I am not really a programmer so I was looking for something that would work with the already setup asp login that comes with visual studio
0
 
LVL 27

Expert Comment

by:BigRat
ID: 34909355
Hmmm, I don't really know. You'll probably have to shop around. This might work, it needs at least to be ASP:NET 2 compatible for the Group Validation to work.

http://captcha.biz/asp.net-captcha.html
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

29 Experts available now in Live!

Get 1:1 Help Now