Solved

RECAPTHA WITH VISUAL STUDIO LOGIN FORM

Posted on 2011-02-15
7
504 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
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…

774 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