如何解决网站所有者的错误:无效的网站密钥"在MVC?

时间:2018-05-29 11:23:02

标签: asp.net-mvc mvcrecaptcha

我想在我的应用程序中实现google recaptcha,但它会抛出错误。我不知道我做错了什么。

我已经安装了GoogleRecaptcha的nuget包,然后获得了基本上是公钥的site key private key。然后,我在<script src='https://www.google.com/recaptcha/api.js'></script>部分<head><div class="g-recaptcha" data-sitekey="xxxxxxxxxxxx"></div>中加入了web.config。在@using reCAPTCHA.MVC <html> <head> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <form> @using (Html.BeginForm()) { @Html.Recaptcha() @Html.ValidationMessage("ReCaptcha") <input type="submit" value="Register" /> <div class="g-recaptcha" data-sitekey="6LeYD1wUAAAAAIzGhgDrIoI_OD7PUzwTJIQdpqGs"></div> } </form> </body> </html> 中,我添加了密钥。我尝试了不同的按键,但仍然没有工作。

  

网站所有者的错误:网站密钥无效

int weightIndex = Array.FindIndex(values, v => v == "Weight");
int ageIndex = Array.FindIndex(values, v => v == "Age");

1 个答案:

答案 0 :(得分:2)

我已将localhost127.0.0.1添加到域中,现在它对我有效。

相关问题