毛毛的小窝 — 关注技术交流、让我们一起成长

导航

根据域名查IP (DNS解析)

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;
    }

}
 

posted on 2007-12-14 09:49  mjgforever  阅读(675)  评论(0编辑  收藏  举报