C# reCaptcha和SSL网站
我在asp.net mvc下的网页上使用reCaptcha。这个网站有SSL认证,我对reCaptcha有疑问。 这是我查看的代码:C# reCaptcha和SSL网站,c#,asp.net-mvc,ssl,recaptcha,C#,Asp.net Mvc,Ssl,Recaptcha,我在asp.net mvc下的网页上使用reCaptcha。这个网站有SSL认证,我对reCaptcha有疑问。 这是我查看的代码: <script type="text/javascript" src="https://api-secure.recaptcha.net/challenge?k=***Public key****"> </script> <noscript> <iframe src="https://api-secure.recaptch
<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>
我的库版本是1.0.5.0
当我加载注册表时,Opera上出现以下警报:
规则服务器证书与服务器名称匹配。你想接受吗
如果我接受此证书,将显示reCaptcha代码,但如果不接受,则不查看reCaptcha代码
你能帮我吗?
如果您需要有关我的代码的更多信息,请随时与我联系
问候。我认为您需要更改用于包含recaptcha的url。在四月份,很多人都有同样的问题。“api secure.recaptcha.net”过期。如果您将其更改为使用“url”而不是“url”,它肯定会解决您的问题
看起来这个问题以前已经得到了回答:。由于您使用的是.NET库,我认为您的答案是升级您的版本。进一步了解JasonStoltz的答案:
- 您已经在使用最新的DLL版本,不需要更新此版本
- 您可以/应该在视图中使用RecaptchaControlMvc.GenerateCaptcha()方法,而不是编写自己的方法(它将使用新的URL)
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;
}
}