如何获取我的站点的客户端IPAddress [英] how to get client IPAddress of my site
本文介绍了如何获取我的站点的客户端IPAddress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码在这里:
my code is here:
string myHost = System.Net.Dns.GetHostName();
System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);
foreach (System.Net.IPAddress myIP in myIPs.AddressList)
{
TextBox1.Text = myIP.ToString();
}
推荐答案
1个Google搜索导致: ^ ]
更好的链接 BitBotBop提示! [ ^ ]
Google搜索此处 [
1 google search leads to: this[^]
better link BitBotBop hint![^]
Google search here[^]
检查此
http://www.daniweb.com/software-development/csharp/threads/396356 [ ^ ]
http://www.csharp-examples.net/local-ip/ [
Check This Out
http://www.daniweb.com/software-development/csharp/threads/396356[^]
http://www.csharp-examples.net/local-ip/[^]
使用
TextBox1.Text = myIP[0].ToString();
如
as
try
{
string sHostName = textBox1.Text;
System.Net.IPHostEntry ipE = System.Net.Dns.GetHostEntry(sHostName);
System.Net.IPAddress[] IpA = ipE.AddressList;
textBox2.Text = IpA[0].ToString();
}
catch(Exception ex)
{
textBox2.Text = ex.ToString();
}
这篇关于如何获取我的站点的客户端IPAddress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文