0

我需要帮助解决的 3 个问题

我已采取的步骤摘要:

  1. 我安装了 reCAPTCH.MCV,然后在 web.config 中安装了公共和私有站点密钥

  2. </head>我在 Header.ascx的标签上方安装了 java 脚本

  3. 我在客户端contactform.aspx上安装了自动渲染DIV元素recaptcha v2

  4. 我在contactform.aspx.cs 安装了服务器端代码-

我的问题是:

  1. Google 管理员页面验证错误:

    "We detected that your site is not verifying reCAPTCHA solutions. This is required for the proper use of reCAPTCHA on your site."  
    
  2. 如何合并 2 个提交按钮?鉴于我在已经有提交按钮的现有联系表单上安装 reCaptcha V2,我不明白如何处理谷歌代码附带的新提交按钮

    <!-- This is the recaptcha code from Google that I have placed in my contact form -->
    <form action="?" method="POST">
      <div class="g-recaptcha" data-sitekey="asdfghghjkhjkhjketc..."></div>
       <input type="submit" value="Submit">
             </form>
    <!-- This is the submit button that already exists at the end of my existing form on contactform.aspx -->
    <asp:Button runat="server" id="btnSubmit" onClick="btnSubmit_Click" Text="Submit"/>
    

    所以我尝试删除谷歌提供的提交输入并将标签移动到我现有的提交按钮下方。页面加载和复选框运行,表单提交,但我显然遗漏了一些东西,因为验证不起作用(根据上面的第 1 项)

  3. 在 .cs 页面上 - 我只是想知道我是否正确地执行了此操作 - 或者我可能遗漏了什么?

    using System.Net; //this was already installed
    using System.Collections.Specialized; // I installed this

然后我安装了

public bool VerifyReCaptcha(string ipAddress, string challengeField, string responseField)
{
    string result = "";
    using (WebClient client = new WebClient())
    {
        byte[] response =
        client.UploadValues("http://www.google.com/recaptcha/api/verify", new 
NameValueCollection()
        {
    { "privatekey", "123123asfdasdfgsdfsggsdgfsdfsgd" },
    { "remoteip", ipAddress },
    { "challenge", challengeField },
    { "response", responseField },
        });

        result = System.Text.Encoding.UTF8.GetString(response);
    }

    return result.StartsWith("true");
}
4

0 回答 0