You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用BlogEngine集成Recaptcha v2时持续返回'missing-input-secret'错误求助

解决Recaptcha v2返回'missing-input-secret'错误的方案

问题根源

你提供的RecaptchaValidator.cs代码中,构造POST请求表单数据时存在核心错误:

  • String.Format未使用参数占位符模板,导致三个参数直接拼接成无意义字符串,谷歌无法识别参数键名
  • 未按照Recaptcha v2要求构造secret、response、remoteip的键值对格式参数

修复步骤

替换formdata的构造代码:

原错误代码:

var formdata = String.Format(
    HttpUtility.UrlEncode(this.PrivateKey),
    HttpUtility.UrlEncode(this.Response),
    HttpUtility.UrlEncode(this.RemoteIP));

修改为正确的参数格式:

var formdata = string.Format(
    "secret={0}&response={1}&remoteip={2}",
    HttpUtility.UrlEncode(this.PrivateKey),
    HttpUtility.UrlEncode(this.Response),
    HttpUtility.UrlEncode(this.RemoteIP));

额外验证项

  • 确认PrivateKey是谷歌Recaptcha控制台生成的v2私钥,而非公钥
  • 检查VerifyUrl是否为v2验证端点:https://www.google.com/recaptcha/api/siteverify(v1端点与v2不兼容)
  • 确保RemoteIP获取的是用户真实IP,未被代理/反向代理篡改

内容的提问来源于stack exchange,提问作者leof

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 06:25:27