Bilgisayarın çıkış yaptığı internet dış IP'yi bulmak (WhatismyIP.com işlevini görür)

Kullanılan sistemlerde çıkış yaptığınız IP'yi kontrol etmek için aşağıdaki prosedür kullanılabilir. Bu https://www.whatismyip.com/ adresindeki gibi dış IP'yi bulmaya yarar.




 Procedure: 
 private static string GetExternalIp()
        {
            String direction = "";
            WebRequest request = WebRequest.Create("http://checkip.dyndns.org/");
            using (WebResponse response = request.GetResponse())
            using (StreamReader stream = new StreamReader(response.GetResponseStream()))
            {
                direction = stream.ReadToEnd();
            }
            int first = direction.IndexOf("Address: ") + 9;
            int last = direction.LastIndexOf("
");            direction = direction.Substring(first, last - first);
            return direction;
        }


Kullanımı: 
         private void button2_IpGoster(object sender, EventArgs e)
        {
            string externalIP =  GetExternalIp();
        }

Hiç yorum yok:

BlackListIP control on Serenity platform (.NET Core)

 In the Serenity platform, if you want to block IPs that belong to people you do not want to come from outside in the .net core web project,...