0

I am trying to use Google Recaptcha on on my web pages. I keep getting an error saying

GoogleReCaptcha.GoogleReCaptcha)(System.Web.HttpRuntime.WebObjectActivator.GetService(typeof(GoogleReCaptcha.GoogleReCaptcha))));

Below is the screen shot:

enter image description here

Below is my aspx page code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TryAgain.WebForm1" %>
<%@ Register Assembly="GoogleReCaptcha" Namespace="GoogleReCaptcha" TagPrefix="cc1" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
             <p>
        <h1>Google ReCaptcha Form</h1>
        <asp:TextBox ID="txt" runat="server"></asp:TextBox>
        <cc1:GoogleReCaptcha ID="ctrlGoogleReCaptcha" runat="server" PublicKey="XXXX" PrivateKey="XXX" />
        <asp:Panel ID="Panel1" runat="server">
        </asp:Panel>
        <asp:Label ID="lblStatus" runat="server" Text=""></asp:Label>
        <asp:Button ID="btn" runat="server" Text="Submit" OnClick="btn_Click" />
    </p>
        </div>
    </form>
</body>
</html>

Below is my aspx.cs file code:

   protected void btn_Click(object sender, EventArgs e)
        {
            if (ctrlGoogleReCaptcha.Validate())
            {
                //submit form
                lblStatus.Text = "Success";
            }
            else
            {
                lblStatus.Text = "Captcha Failed!! Please try again!!";
            }
        }

GoogleRecaptcha that I downloaded has properties like so:

enter image description here

I am struggling with this error for hours. Any help will be highly appreciated.

Anjali
  • 2,540
  • 7
  • 37
  • 77
  • "The Type Name 'GoogleReCaptcha' does not exist in the type 'GoogleReCaptcha'". Your code `typeof(GoogleReCaptcha.GoogleReCaptcha)` claims that it does. – Robert Harvey Jun 18 '20 at 22:39
  • Yes, I know. I am not sure why it is doing that – Anjali Jun 18 '20 at 22:58
  • It's doing that because there is no public member in the `GoogleReCaptcha` class that is of type `GoogleReCaptcha`. Why would there be? – Robert Harvey Jun 18 '20 at 22:59
  • should I create a public member called GoogleReCaptcha – Anjali Jun 18 '20 at 23:15
  • Well, let's start by talking about your existing code. Did you write that, or did you get it from somewhere on the Internet? – Robert Harvey Jun 18 '20 at 23:27
  • I got it from here: https://www.codeproject.com/Tips/884193/Google-ReCaptcha-ASP-net-Control – Anjali Jun 18 '20 at 23:28
  • I can change the code. I just need little bit help. – Anjali Jun 18 '20 at 23:55
  • It doesn't look like I'm going to have time to dig into that Code Project code right now. But I don't think it makes much sense for the GoogleReCaptcha class to have a recursive member in it. It's possible, but very unlikely. – Robert Harvey Jun 19 '20 at 00:06

0 Answers0