龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp.net编程 >

asp.net根据域名查ip C#版

时间:2009-12-21 11:47来源:未知 作者:admin 点击:
分享到:
网上有类似的教程,但是是asp.net 1.1的版本,这是本人写的,asp.net 2.0支持。

        public string GetIPByDomain(string url)
        {
            if (url.Trim() == string.Empty)
                return "";
            try
            {
                System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(url);
                return host.AddressList.GetValue(0).ToString();
            }
            catch (Exception e)
            { 
                throw e;
            }
       }

调用方法: GetIPByDomain("www.it55.com")

精彩图集

赞助商链接