如题。
假设你的机器是web服务器,在我这里访问那个网页,显示的就是我机器的外网IP。在你的机器上访问就是本机IP。
方法1:
this.Label1.Text = Request.UserHostAddress.ToString();
方法2:
string strHostIP = "";
IPHostEntry oIPHost = Dns.Resolve(Environment.MachineName);
if (oIPHost.AddressList.Length > 0)
strHostIP = oIPHost.AddressList[0].ToString();
this.TextBox1.Text = strHostIP;