Reputation: 313
I want to implement google recaptcha into my application but it is throwing the error. I do not know what I have done wrong.
I have installed nuget package of GoogleRecaptcha
and then got the site key
which is basically a public key and private key
. I then included <script src='https://www.google.com/recaptcha/api.js'></script>
in <head>
section and <div class="g-recaptcha" data-sitekey="xxxxxxxxxxxx"></div>
into form. In web.config
, I have added the keys. I tried different keys but still not working.
ERROR for site owner: Invalid site key
@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>
Upvotes: 1
Views: 6090
Reputation: 313
I have added localhost
and 127.0.0.1
to domains and it worked for me now.
Upvotes: 2