{"id":22125089,"url":"https://github.com/henriqb/recaptcha-asp-net","last_synced_at":"2025-04-10T01:10:56.610Z","repository":{"id":35809907,"uuid":"40092300","full_name":"henriqb/ReCaptcha-Asp-Net","owner":"henriqb","description":"Google ReCaptcha for Asp Net, simplified","archived":false,"fork":false,"pushed_at":"2019-10-14T23:41:08.000Z","size":198,"stargazers_count":56,"open_issues_count":1,"forks_count":23,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T01:10:49.821Z","etag":null,"topics":["aspnet","c-sharp","google-recaptcha","recaptcha-asp-net"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/henriqb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-02T20:46:32.000Z","updated_at":"2024-03-20T23:45:21.000Z","dependencies_parsed_at":"2022-09-05T07:00:43.828Z","dependency_job_id":null,"html_url":"https://github.com/henriqb/ReCaptcha-Asp-Net","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henriqb%2FReCaptcha-Asp-Net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henriqb%2FReCaptcha-Asp-Net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henriqb%2FReCaptcha-Asp-Net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henriqb%2FReCaptcha-Asp-Net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henriqb","download_url":"https://codeload.github.com/henriqb/ReCaptcha-Asp-Net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137886,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnet","c-sharp","google-recaptcha","recaptcha-asp-net"],"created_at":"2024-12-01T16:17:00.207Z","updated_at":"2025-04-10T01:10:56.583Z","avatar_url":"https://github.com/henriqb.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReCaptcha-Asp-Net\nGoogle ReCaptcha for Asp Net, simplified\n\n## Installation\nNuget Url:\nhttps://www.nuget.org/packages/ReCaptcha-AspNet\n\n```\nPM \u003e Install-Package ReCaptcha-AspNet\n```\n\n## Configuration \n\nGet your secret and public keys on https://www.google.com/recaptcha/admin \n\nAdd to you App/Web.config inside \u003cappSettings\u003e\n```xml\n\u003cadd key=\"recaptcha-secret-key\" value=\"...[secret key]\" /\u003e\n\u003cadd key=\"recaptcha-public-key\" value=\"...[public-key]\" /\u003e\n```\nOptional if you want to alter the default language of the Captcha (Get the language code on ReCaptcha site: https://developers.google.com/recaptcha/docs/language)\nOr you can use value \"Auto\" and it will get the Language from System.Thread.CurrentCulture\n```xml\n\u003cadd key=\"recaptcha-language-key\" value=\"[language-code]\" /\u003e\n```\nOr via C# code:\nIt's only needed to call it once, a good place to put this is at Application_Start() function \n```C#\nstring publicKey = \"...[public-key]\";\nstring secretKey = \"...[secret-key]\";\nReCaptcha.Configure(publicKey, secretKey);\n\n// Optional, select a default language:\nReCaptchaLanguage defaultLanguage = ReCaptchaLanguage.German;\nReCaptcha.Configure(publicKey, secretKey, defaultLanguage);\n\n//Auto-select language from System.Thread.CurrentCulture\nReCaptchaLanguage defaultLanguage = ReCaptchaLanguage.Auto;\nReCaptcha.Configure(publicKey, secretKey, defaultLanguage);\n```\n\nOptional if you want to alter the default theme from light to dark mode.\n```xml\n\u003cadd key=\"recaptcha-language-theme\" value=\"dark\" /\u003e\n```\n\nOr via C# code:\n```C#\n//Optional select a default dark theme\nReCaptchaLanguage defaultLanguage = ReCaptchaLanguage.Auto;\nReCaptcha.Configure(publicKey, secretKey, defaultLanguage, ReCaptchaTheme.dark);\n```\n\n## How to use\n\n### Client Side (v2):\nInside your form \n```html\n\u003cform action=\"myAction\"\u003e\n  \u003cinput type=\"text\" name=\"myinput1\" /\u003e\n  @ReCaptcha.GetCaptcha() \u003c!-- Will show your captcha as your configured Language, \n  if no language is defined it will show ReCaptcha default language (English) --\u003e\n\u003c/form\u003e\n```\n\nOptional if you want to override your configured default language: \n```html\n\u003cform action=\"myAction\"\u003e\n  \u003cinput type=\"text\" name=\"myinput1\" /\u003e\n  @ReCaptcha.GetCaptcha(ReCaptchaLanguage.PortugueseBrazil) \u003c!-- Will show your ReCaptcha as Portuguese, \n  overriding any previous configuration --\u003e\n\u003c/form\u003e\n```\n\nOptional if you want to override your configured theme (light/dark): \n```html\n\u003cform action=\"myAction\"\u003e\n  \u003cinput type=\"text\" name=\"myinput1\" /\u003e\n  @ReCaptcha.GetCaptcha(theme: ReCaptchaTheme.dark) \u003c!-- Will show your ReCaptcha on dark theme, \n  overriding any previous configuration --\u003e\n\u003c/form\u003e\n```\n\n### Client Side (Invisible):\nInside your form \n```html\n\u003cscript type=\"text/javascript\"\u003efunction submit() { $('form').submit(); }\u003c/script\u003e\n\u003cform action=\"myAction\"\u003e\n  \u003cinput type=\"text\" name=\"myinput1\" /\u003e\n  @ReCaptcha.GetInvisibleCaptcha(\"submit\", \"Save\") \u003c!-- Will show a button, with a Label Save and  call function \"submit();\" after user click ok and pass Captcha --\u003e\n\u003c/form\u003e\n```\n\nOptional if you want to override your configured default language: \n```html\n\u003cscript type=\"text/javascript\"\u003efunction submit() { $('form').submit(); }\u003c/script\u003e\n\u003cform action=\"myAction\"\u003e\n  \u003cinput type=\"text\" name=\"myinput1\" /\u003e\n  @ReCaptcha.GetInvisibleCaptcha(\"submit\", \"Save\", ReCaptchaLanguage.PortugueseBrazil) \u003c!-- Will show your Invisible ReCaptcha as Portuguese, overriding any previous configuration --\u003e\n\u003c/form\u003e\n```\n\n### Server Side:\nInside your controller function or in a filter\n```C#\nstring userResponse = HttpContext.Request.Params[\"g-recaptcha-response\"];\nbool validCaptcha = ReCaptcha.ValidateCaptcha(userResponse);\nif (validCaptcha){\n  // Real User, validated !\n  DoStuff();\n  ...\n} else {\n  // Bot Attack, non validated !\n  return RedirectToAction(\"YouAreARobot\", \"Index\");\n}\n```\n\n#### Optional: Proxy\nYou may use a Proxy to send user Response to ReCaptcha Server\n```C#\n...\nconst string proxyIp = \"xxx.xxx.xxx.xxx\";\nconst int proxyPort = 1234;\nWebProxy webProxy = new WebProxy(proxyIp, proxyPort); \nbool validCaptcha = ReCaptcha.ValidateCaptcha(userResponse, webProxy);\n...\n``` \n\nMay throws the following exception, if the secret key is invalid, or you pass a invalid user response as the ValidateCaptcha parameter:\n```C#\nthrow new ReCaptchaException();\n```\n\nIt can also be called async:\n```C#\npublic async ActionResult MyFunction() {\n  string userResponse = HttpContext.Request.Params[\"g-recaptcha-response\"];\n  var validCaptcha = ReCaptcha.ValidateCaptchaAsync(userResponse);\n  DoSomeParallelStuff();\n  \n  if (await validCaptcha){\n    // Real User, validated !\n    DoStuff();\n    ...\n  } else {\n    // Bot Attack, non validated !\n    return RedirectToAction(\"YouAreARobot\", \"Index\");\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenriqb%2Frecaptcha-asp-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenriqb%2Frecaptcha-asp-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenriqb%2Frecaptcha-asp-net/lists"}