Sitenize googlenin yeni recaptcha(her seferinde nasıl yazılıyo diye baktığım kelime 😀 😀 ) daha kullanışlı olan 2014 model sürümü çıkmış bende asp.net ile uyumlu bir sürün bulamadım kendi entegre ettiğim kodları paylaşmaş istedim.
Detaylı bilgiyi aşağıdaki linkten bulabilirsiniz.
https://www.google.com/recaptcha/intro/index.html
(ben saksı değilim sürümünü merakla bekliyoruz 😀 😀 )
Bot dogrulama için fonksiyonlarmız
static string site_key = "sizin site keyiniz"; static string secret_key = "sizin secret keyiniz"; public static string botDogrulamaHtmlOlustur() { string html = @"<script type=""text/javascript"" src='https://www.google.com/recaptcha/api.js'></script> <div class=""g-recaptcha"" data-sitekey=" + site_key + "></div>"; return html; } public static bool BotDogrulama() { string Response = HttpContext.Current.Request["g-recaptcha-response"];//Getting Response String Append to Post Method bool Valid = false; //Request to Google Server System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("https://www.google.com/recaptcha/api/siteverify?secret=" + secret_key + "&response=" + Response); try { //Google recaptcha Response using (System.Net.WebResponse wResponse = req.GetResponse()) { using (StreamReader readStream = new StreamReader(wResponse.GetResponseStream())) { string jsonResponse = readStream.ReadToEnd(); System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); GoogleApiJsonModel data = js.Deserialize<GoogleApiJsonModel>(jsonResponse);// Deserialize Json Valid = Convert.ToBoolean(data.success); } } return Valid; } catch { return false; } } public class GoogleApiJsonModel { public string success { get; set; } }
Bot dogrulama sayfamız
öncelikle asp.net sayfamaza bir label eklememiz gerekiyor.bu labele dogrulama kdounu yerleştireceğiz
kod:
lbl_bot_dogrula.Text = botDogrulamaHtmlOlustur();
Bir adet butonuma ise formun doğrulandığını kontrol eden fonksişyonumuz yazıyoruz.Buton click olayına
Button1_Click
if(genelFonk.BotDogrulama()){ //doğrulama başarılı }
Yıllar önce MSSQL veritabanından PSQL veritabanına geçiş yaparken aldığım notları sizinle paylaşmak istedim . Umarım…
Dosyalarınızı farklı bir sunucu üzerinde barındırmaya karar vermişseniz minio ile karşılaşmısınızdır.Bende minio serveri kendi projelerimde…
Osticket 1.12.x ve 1..14.x sürümleri ile uyumulu olan Saml eklentisini github sayfamda yayınlamış bulunmaktayım.
Yeni WordPress editörü (Gutenberg) 5.0 sürümünde yayınlanmıştır. Şimdi WordPress çekirdeğine inmeden önce onunla başa çıkmanın tam…
HaProxy ve Ngix ile suncuu yük dağılımı yapılabiliyor.Şimdi popüler olan araç ise Traefik ( Bu…
View Comments
Teşekkürler :)
Teşekkürler :)