【问题标题】:Validating reCaptcha on asp.net form在 asp.net 表单上验证 reCaptcha
【发布时间】:2016-08-13 21:39:39
【问题描述】:

我已将其包含在我的 .ascx 文件中

<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" style="max-width:100%; width:300px;margin:0 auto;" data-sitekey="I_PUT_MY_SITEKEY_HERE"></div>

这是我的 .ascx.cs 文件中的内容

protected void SubmitButton_Click(object sender, EventArgs e)
{
    Page.Validate();
    if (Page.IsValid)
    {
        try
        {
            //this is where all the email template code is, not important
        }
        catch (Exception ex)
        {
            Logger.Error("Contact Form", ex);
        }
    }

}

如您所见,我正在尝试在单击提交按钮时验证验证码,如果验证码有效,则通过联系表单发送电子邮件。我哪里错了?验证码显示正常,只需要它与表单一起使用即可。

【问题讨论】:

    标签: asp.net validation captcha


    【解决方案1】:

    Page.IsValid 仅验证 asp.net 控件。验证 ReCaptcha 需要额外的工作。您可以在https://developers.google.com/recaptcha/docs/verify中阅读方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-02
      • 1970-01-01
      • 2016-03-12
      • 2015-02-11
      • 1970-01-01
      • 2020-06-13
      相关资源
      最近更新 更多