i have a model and surface controller for contact form and i want to put a google recapcha on it.
how do i do this?
public class ContactModel
{
[Required]
[DisplayName("First name")]
public string Name { get; set; }
[Required]
[DisplayName("Email address")]
public string Email { get; set; }
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Contact(ContactModel model)
{
var response = Request["g-recaptcha-response"];
string secretKey = "6LfJeQgUAAAAAEhworh47HsU1-zSUH3LlWmLd3yx"; // Ur secretKey
var webClient = new WebClient();
var result = webClient.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response));
var obj = JObject.Parse(result);
var status = (bool)obj.SelectToken("success");
if (ModelState.IsValid && status == true)
{
//Ur code to send message
TempData["ContactSuccess"] = "success";
return RedirectToCurrentUmbracoPage();
}
return CurrentUmbracoPage();
}
google recapcha on surface controller
i have a model and surface controller for contact form and i want to put a google recapcha on it. how do i do this?
the form partial
and the controller
Hi Philip Christianto.
and in ur view :
don't forget to add
Hi
For Umbraco Forms forms you can use ReCaptcha package:
https://our.umbraco.org/projects/collaboration/recaptcha-field-for-umbraco-forms/
Thanks,
Alex
is working on a reply...