通过域名获取IP[转帖]

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");

转自:http://www.chenjiliang.com/Article/View.aspx?ArticleID=4150&TypeID=84
posted @ 2008-09-11 12:34  liangwei389  Views(395)  Comments(0Edit  收藏  举报