بدست آوردن آدرس IP از روی DNS HostName در C#

private void Button1_Click(object sender, EventArgs e) { textBoxIP.Text = GetIP(GetHostName("http://mds-soft.persianblog.ir/post/100/")); }

/// <summary> /// Returns the Host name from a web address /// </summary> private string GetHostName(string WebAddress) { string HostName = ""; string OriginalUrl = WebAddress.Trim(); Uri uri;

if (!Uri.TryCreate(WebAddress, UriKind.Absolute, out uri)) HostName = new UriBuilder(WebAddress).Host; else HostName = uri.Host;

return HostName; }

/// <summary> /// Returns the IP of HostName /// </summary> private string GetIP(string HostName) { IPAddress[] addresslist = Dns.GetHostAddresses(HostName); return addresslist[0].ToString(); }

/ 1 نظر / 25 بازدید
Mehdi

salam mishe in barnamasho baraye man E-mail konid? mamnuneton misham [گل]