Get Client IP (IP4Address)

【Call Function】

lblGetClientIP.text=GetIP4Address();

【Function】

 using System.Net;      

        public static string GetIP4Address()
        {
            string IP4Address = String.Empty;
            foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
            {
                if (IPA.AddressFamily.ToString() == "InterNetwork")
                {
                    IP4Address = IPA.ToString();
                    break;
                }
            }
            return IP4Address;
        }

 

Reference:http://stackoverflow.com/questions/6668810/c-sharp-get-ipv4-ipaddress-only

文章標籤
全站熱搜
創作者介紹
創作者 以戒為師 的頭像
以戒為師

老實念佛,以戒為師

以戒為師 發表在 痞客邦 留言(0) 人氣(969)