Pip*_*ine 4 c# asp.net-mvc ssl recaptcha
我在asp.net mvc下的网页上使用了reCaptcha.这个网站有SSL认证,我有reCaptcha和问题.这是我在View上的代码:
<script type="text/javascript" src="https://api-secure.recaptcha.net/challenge?k=***Public key****"> </script>
<noscript>
<iframe src="https://api-secure.recaptcha.net/noscript?k=***Public key****" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
</noscript>
Run Code Online (Sandbox Code Playgroud)
这个代码是我在AccountController上的代码:
private bool PerformRecaptcha()
{
var validator = new RecaptchaValidator
{
PrivateKey = "**Private Key***",
RemoteIP = Request.UserHostAddress,
Response = Request.Form["recaptcha_response_field"],
Challenge = Request.Form["recaptcha_challenge_field"]
};
try
{
var validationResult = validator.Validate();
if (validationResult.ErrorMessage == "incorrect-captcha-sol")
ModelState.AddModelError("ReCaptcha", string.Format("Please retry the ReCaptcha portion again."));
return validationResult.IsValid;
}
catch (Exception e)
{
ModelState.AddModelError("ReCaptcha", "an error occured with ReCaptcha please consult documentation.");
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我的库版本是1.0.5.0.
当我加载注册表单时,我在Opera上有这个警告:
规则服务器证书与服务器名称匹配.你想接受吗?
如果我接受此证书,则显示reCaptcha代码,但如果没有,我不会查看reCaptcha代码.
你能帮帮我吗?如果您需要有关我的代码的更多信息,请随时向我询问.
问候.
Jas*_*ltz 10
我认为您需要更改您使用的网址以包含recaptcha.很多人在四月遇到了同样的问题.Recaptcha让证书到期为"api-secure.recaptcha.net".如果您将其更改为使用" https://www.google.com/recaptcha/api/XXX "网址而不是" https://api-secure.recaptcha.net/XXX ",那么它肯定会解决您的问题.
看起来这个实际上已经得到了回答:https : //api-secure.recaptcha.net/上的recaptcha https问题.由于您使用的是.NET库,我认为您的答案是升级您的版本.
| 归档时间: |
|
| 查看次数: |
3921 次 |
| 最近记录: |