{"id":158,"date":"2025-05-04T09:51:27","date_gmt":"2025-05-04T09:51:27","guid":{"rendered":"https:\/\/www.webmobkey.com\/blog\/?p=158"},"modified":"2025-11-16T10:22:20","modified_gmt":"2025-11-16T10:22:20","slug":"asp-net-core-ile-google-recaptcha-entegrasyonu","status":"publish","type":"post","link":"https:\/\/www.webmobdesign.com\/blog\/tr\/asp-net-core-ile-google-recaptcha-entegrasyonu\/","title":{"rendered":"ASP.NET Core ile Google reCAPTCHA Entegrasyonu"},"content":{"rendered":"\n<p id=\"f48a\">Bu blog yaz\u0131s\u0131nda, ASP.NET Core projenize Google reCAPTCHA entegrasyonunu nas\u0131l ekleyece\u011finizi ad\u0131m ad\u0131m anlataca\u011f\u0131m. reCAPTCHA, web sitenizi botlardan korumak i\u00e7in kullan\u0131lan pop\u00fcler bir ara\u00e7t\u0131r.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cc01\">1. Google reCAPTCHA Anahtarlar\u0131n\u0131 Olu\u015fturma<\/h2>\n\n\n\n<p id=\"def2\">\u00d6ncelikle,&nbsp;<a href=\"https:\/\/www.google.com\/recaptcha\" rel=\"noreferrer noopener\" target=\"_blank\">Google reCAPTCHA<\/a>&nbsp;sitesine giderek bir hesap olu\u015fturun ve sitenizi kaydedin. Google size bir&nbsp;<code>Site Key<\/code>&nbsp;ve&nbsp;<code>Secret Key<\/code>&nbsp;sa\u011flayacakt\u0131r. Bu anahtarlar reCAPTCHA&#8217;y\u0131 sitenize entegre etmenizi sa\u011flayacakt\u0131r.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0904\">2. Projenize reCAPTCHA Script\u2019ini Ekleyin<\/h2>\n\n\n\n<p id=\"cf2d\">HTML sayfan\u0131z\u0131n&nbsp;<code>&lt;head&gt;<\/code>&nbsp;k\u0131sm\u0131na a\u015fa\u011f\u0131daki script etiketini ekleyin. Bu, reCAPTCHA&#8217;n\u0131n JavaScript API&#8217;sini y\u00fckleyecektir.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n &lt;script src=&quot;https:\/\/www.google.com\/recaptcha\/api.js&quot; async defer&gt;&lt;\/script&gt;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"8b0c\">3. reCAPTCHA Widget\u2019\u0131n\u0131 Sayfan\u0131za Ekleyin<\/h2>\n\n\n\n<p id=\"6fa5\">reCAPTCHA\u2019n\u0131n g\u00f6r\u00fcnece\u011fi yere a\u015fa\u011f\u0131daki kodu ekleyin.&nbsp;<code>data-sitekey<\/code>&nbsp;attribute&#8217;\u00fcne Google&#8217;\u0131n sa\u011flad\u0131\u011f\u0131&nbsp;<code>Site Key<\/code>&nbsp;de\u011ferini girin.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;div class=&quot;g-recaptcha&quot; data-sitekey=&quot;YOUR_SITE_KEY&quot; data-callback=&quot;submit&quot;&gt;&lt;\/div&gt;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"660c\">4. reCAPTCHA Do\u011frulama Metodu Olu\u015fturma<\/h2>\n\n\n\n<p id=\"b9ae\">ASP.NET Core projenizde, reCAPTCHA do\u011frulamas\u0131n\u0131 ger\u00e7ekle\u015ftirmek i\u00e7in bir metot olu\u015fturun. Bu metot, Google\u2019\u0131n reCAPTCHA do\u011frulama API\u2019sine bir HTTP POST iste\u011fi g\u00f6nderir ve cevab\u0131 kontrol eder.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\nprivate async Task&lt;bool&gt; CheckCaptcha()\n{\n    var postData = new List&lt;KeyValuePair&lt;string, string&gt;&gt;()\n    {\n        new KeyValuePair&lt;string, string&gt;(&quot;secret&quot;, &quot;YOUR_SECRET_KEY&quot;),\n        new KeyValuePair&lt;string, string&gt;(&quot;remoteip&quot;, HttpContext.Connection.RemoteIpAddress.ToString()),\n        new KeyValuePair&lt;string, string&gt;(&quot;response&quot;, HttpContext.Request.Form&#x5B;&quot;g-recaptcha-response&quot;])\n    };\n\n    var client = new HttpClient();\n    var response = await client.PostAsync(&quot;https:\/\/www.google.com\/recaptcha\/api\/siteverify&quot;, new FormUrlEncodedContent(postData));\n    var responseString = await response.Content.ReadAsStringAsync();\n    var responseObject = JsonConvert.DeserializeObject&lt;JObject&gt;(responseString);\n\n    return (bool)responseObject&#x5B;&quot;success&quot;];\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"4793\">5. HomeController\u2019da reCAPTCHA Do\u011frulama<\/h2>\n\n\n\n<p id=\"75ad\">Art\u0131k HomeController\u2019da reCAPTCHA do\u011frulamas\u0131n\u0131 kullanabiliriz. Form g\u00f6nderiminde reCAPTCHA yan\u0131t\u0131n\u0131 al\u0131p do\u011frulama metodunu \u00e7a\u011f\u0131raca\u011f\u0131z.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\npublic async Task&lt;IActionResult&gt; SubmitForm()\n{\n    var captchaImage = HttpContext.Request.Form&#x5B;&quot;g-recaptcha-response&quot;];\n    if (string.IsNullOrEmpty(captchaImage))\n    {\n        TempData&#x5B;&quot;HataMesaji&quot;] = &quot;L\u00fctfen reCAPTCHA do\u011frulamas\u0131n\u0131 tamamlay\u0131n.&quot;;\n        return View();\n    }\n\n    var verified = await CheckCaptcha();\n    if (verified)\n    {\n        \/\/ reCAPTCHA do\u011frulamas\u0131 ba\u015far\u0131l\u0131\n        \/\/ Form i\u015flemlerini burada ger\u00e7ekle\u015ftirin\n    }\n    else\n    {\n        TempData&#x5B;&quot;HataMesaji&quot;] = &quot;reCAPTCHA do\u011frulamas\u0131 ba\u015far\u0131s\u0131z. L\u00fctfen tekrar deneyin.&quot;;\n        return View();\n    }\n\n    return RedirectToAction(&quot;Success&quot;);\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"a1a5\">6. Form G\u00f6nderiminde reCAPTCHA Do\u011frulama<\/h2>\n\n\n\n<p id=\"8ab9\">Formunuzu g\u00f6nderdi\u011finizde reCAPTCHA do\u011frulamas\u0131 yap\u0131lacak ve sonuca g\u00f6re i\u015flemler ger\u00e7ekle\u015ftirecektir. reCAPTCHA do\u011frulamas\u0131 ba\u015far\u0131s\u0131zsa kullan\u0131c\u0131ya hata mesaj\u0131 g\u00f6sterilir, ba\u015far\u0131l\u0131ysa form i\u015fleme al\u0131n\u0131r.<\/p>\n\n\n\n<p id=\"5395\">Bu ad\u0131mlar\u0131 izleyerek, ASP.NET Core projenize Google reCAPTCHA entegrasyonunu ekleyebilir ve web sitenizi botlardan koruyabilirsiniz. Bu s\u00fcre\u00e7te dikkat etmeniz gereken en \u00f6nemli nokta,&nbsp;<code>Site Key<\/code>&nbsp;ve&nbsp;<code>Secret Key<\/code>&nbsp;de\u011ferlerinizi g\u00fcvende tutmakt\u0131r.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bu blog yaz\u0131s\u0131nda, ASP.NET Core projenize Google reCAPTCHA entegrasyonunu nas\u0131l ekleyece\u011finizi ad\u0131m ad\u0131m anlataca\u011f\u0131m. reCAPTCHA, web &hellip; <a title=\"ASP.NET Core ile Google reCAPTCHA Entegrasyonu\" class=\"hm-read-more\" href=\"https:\/\/www.webmobdesign.com\/blog\/tr\/asp-net-core-ile-google-recaptcha-entegrasyonu\/\"><span class=\"screen-reader-text\">ASP.NET Core ile Google reCAPTCHA Entegrasyonu<\/span>Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-web-tr"],"_links":{"self":[{"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":1,"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":326,"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/posts\/158\/revisions\/326"}],"wp:attachment":[{"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webmobdesign.com\/blog\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}