IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
string myip = IpEntry.AddressList[0].ToString();
这样,如果没有安装IPV6协议,可以取得IP地址. 但是如果安装了IPV6,就取得的是IPV6的IP地址.
string myip = IpEntry.AddressList[1].ToString();
这样就在IPV6的情况下取得IPV4的IP地址.
但是,如果本机有很多块网卡, 如何得到IpEntry.AddressList[多少]才是本机的局网IPV4地址呢?
107 个解决方案
#1
#2
初学者 不会 O(∩_∩)O~ 学习 !~!!~!
#3
ding...
#4
路过,学习了!!~
#5
其实你实现下就知道了。。
#6
IPHostEntry IPHost = Dns.Resolve(hostname);
Console.WriteLine(IPHost.HostName);
string []aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
Console.WriteLine(addr[0]);
没记错的话是0
Console.WriteLine(IPHost.HostName);
string []aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
Console.WriteLine(addr[0]);
没记错的话是0
#7
学习了
#8
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
namespace Network
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 0;
this.label1.Text = "主机名:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(96, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(192, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "IP地址:";
//
// textBox2
//
this.textBox2.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textBox2.Location = new System.Drawing.Point(96, 56);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(192, 21);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(64, 96);
this.button1.Name = "button1";
this.button1.TabIndex = 4;
this.button1.Text = "获取";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(184, 96);
this.button2.Name = "button2";
this.button2.TabIndex = 5;
this.button2.Text = "关闭";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 142);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "演示获取主机名和IP地址";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button2_Click(object sender, System.EventArgs e)
{//关闭程序
this.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{//获取本机IP地址
string HostName=Dns.GetHostName();
this.textBox1.Text=HostName;
IPHostEntry MyEntry=Dns.GetHostByName(Dns.GetHostName());
IPAddress MyAddress=new IPAddress(MyEntry.AddressList[0].Address);
this.textBox2.Text=MyAddress.ToString();
}
}
}
#9
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection nics = mc.GetInstances();
foreach (ManagementObject nic in nics)
{
if (Convert.ToBoolean(nic["ipEnabled"]) == true)
{
Console.WriteLine((nic["IPAddress"] as String[])[0]);
}
}
ManagementObjectCollection nics = mc.GetInstances();
foreach (ManagementObject nic in nics)
{
if (Convert.ToBoolean(nic["ipEnabled"]) == true)
{
Console.WriteLine((nic["IPAddress"] as String[])[0]);
}
}
#10
winform的我不知道
webform的用
Request.ServerVariables["REMOTE_ADDR"]//客户端IP
webform的用
Request.ServerVariables["REMOTE_ADDR"]//客户端IP
#11
System.Net.IPHostEntry IpEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
for (int i = 0; i != IpEntry.AddressList.Length; i++)
{
if (!IpEntry.AddressList[i].IsIPv6LinkLocal)
{
MessageBox.Show(IpEntry.AddressList[i].ToString());
}
}
for (int i = 0; i != IpEntry.AddressList.Length; i++)
{
if (!IpEntry.AddressList[i].IsIPv6LinkLocal)
{
MessageBox.Show(IpEntry.AddressList[i].ToString());
}
}
#12
学习
#13
牛人
#14
顶……
#15
真的,倒没想过IPV6这个问题,提醒我了
#16
学习
#17
学习
#18
IPAddress.AddressFamily 属性
对于 IPv4,返回 InterNetwork;对于 IPv6,返回 InterNetworkV6。
对于 IPv4,返回 InterNetwork;对于 IPv6,返回 InterNetworkV6。
#19
18楼正解,其他楼层都不对
#20
过来学习
#21
学习了
#22
/// <summary>
/// 获取客户端IP地址
/// </summary>
/// <returns></returns>
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}
else
{
ip = request.UserHostAddress;
}
}
catch (Exception e)
{
throw e;
}
return ip;
}
/// 获取客户端IP地址
/// </summary>
/// <returns></returns>
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}
else
{
ip = request.UserHostAddress;
}
}
catch (Exception e)
{
throw e;
}
return ip;
}
#23
Up
#24
学习了
以前知道4的,没有研究过6的
以前知道4的,没有研究过6的
#25
同意通过AddressFamily 属性判断。
另外,本机ipv4也完全可能是多于1个地址的,不要以为只能有1个。
另外,本机ipv4也完全可能是多于1个地址的,不要以为只能有1个。
#26
#27
学习了
#28
汗,有这么复杂吗
using System.Net;
//方法一:
string strHostIP = "";
IPHostEntry oIPHost = Dns.Resolve(Environment.MachineName);
if (oIPHost.AddressList.Length > 0)
strHostIP = oIPHost.AddressList[0].ToString();
//方法二:
string ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
using System.Net;
//方法一:
string strHostIP = "";
IPHostEntry oIPHost = Dns.Resolve(Environment.MachineName);
if (oIPHost.AddressList.Length > 0)
strHostIP = oIPHost.AddressList[0].ToString();
//方法二:
string ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
#29
IPAddress.getHost()
的一些属性 可以得到
的一些属性 可以得到
#30
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Collections.Specialized;
namespace GetIpv4Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ShowIP();
}
void ShowIP()
{
//ipv4地址也可能不止一个
foreach(string ip in GetLocalIpv4())
{
this.richTextBoxIPv4.AppendText(ip.ToString());
}
return;
}
string[] GetLocalIpv4()
{
//事先不知道ip的个数,数组长度未知,因此用StringCollection储存
IPAddress[] localIPs;
localIPs = Dns.GetHostAddresses(Dns.GetHostName());
StringCollection IpCollection = new StringCollection();
foreach (IPAddress ip in localIPs)
{
//根据AddressFamily判断是否为ipv4,如果是InterNetWork则为ipv6
if (ip.AddressFamily == AddressFamily.InterNetwork)
IpCollection.Add(ip.ToString());
}
string[] IpArray = new string[IpCollection.Count];
IpCollection.CopyTo(IpArray, 0);
return IpArray;
}
}
}
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Collections.Specialized;
namespace GetIpv4Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ShowIP();
}
void ShowIP()
{
//ipv4地址也可能不止一个
foreach(string ip in GetLocalIpv4())
{
this.richTextBoxIPv4.AppendText(ip.ToString());
}
return;
}
string[] GetLocalIpv4()
{
//事先不知道ip的个数,数组长度未知,因此用StringCollection储存
IPAddress[] localIPs;
localIPs = Dns.GetHostAddresses(Dns.GetHostName());
StringCollection IpCollection = new StringCollection();
foreach (IPAddress ip in localIPs)
{
//根据AddressFamily判断是否为ipv4,如果是InterNetWork则为ipv6
if (ip.AddressFamily == AddressFamily.InterNetwork)
IpCollection.Add(ip.ToString());
}
string[] IpArray = new string[IpCollection.Count];
IpCollection.CopyTo(IpArray, 0);
return IpArray;
}
}
}
#31
学习了,楼主加油。
#32
学习了
#33
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
#34
学习………………
#35
mark
#36
路过,学习了~~~~顶顶顶
#37
正解
#38
lai xue xi de
#39
学习了 好东西
#40
楼上的几种方法都行。
#41
Request.ServerVariables["SERVER_NAME"]
呵呵,希望能帮到你!
呵呵,希望能帮到你!
#42
根据计算机名 获取ip地址,下面是代码:
string hostName=Dns.GetHostName();
this.txtName.Text=hostName;
IPHostEntry Entry=Dns.GetHostByName(Dns.GetHostName());
IPAddress pAddress=new IPAddress(Entry.AddressList[0].Address);
this.txtIDAddress.Text=pAddress.ToString();
string hostName=Dns.GetHostName();
this.txtName.Text=hostName;
IPHostEntry Entry=Dns.GetHostByName(Dns.GetHostName());
IPAddress pAddress=new IPAddress(Entry.AddressList[0].Address);
this.txtIDAddress.Text=pAddress.ToString();
#43
dns类
其他的都是上面高手说的!
其他的都是上面高手说的!
#44
来顶顶~
学习了!
学习了!
#45
楼上全有了
#46
运行不起来啊
#47
学习了
#48
路过,学习了~~~~顶顶顶
#49
#50
不知道是调用哪个类。。。
忘记了。。
忘记了。。
#1
#2
初学者 不会 O(∩_∩)O~ 学习 !~!!~!
#3
ding...
#4
路过,学习了!!~
#5
其实你实现下就知道了。。
#6
IPHostEntry IPHost = Dns.Resolve(hostname);
Console.WriteLine(IPHost.HostName);
string []aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
Console.WriteLine(addr[0]);
没记错的话是0
Console.WriteLine(IPHost.HostName);
string []aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
Console.WriteLine(addr[0]);
没记错的话是0
#7
学习了
#8
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
namespace Network
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 0;
this.label1.Text = "主机名:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(96, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(192, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "IP地址:";
//
// textBox2
//
this.textBox2.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textBox2.Location = new System.Drawing.Point(96, 56);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(192, 21);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(64, 96);
this.button1.Name = "button1";
this.button1.TabIndex = 4;
this.button1.Text = "获取";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(184, 96);
this.button2.Name = "button2";
this.button2.TabIndex = 5;
this.button2.Text = "关闭";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 142);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "演示获取主机名和IP地址";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button2_Click(object sender, System.EventArgs e)
{//关闭程序
this.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{//获取本机IP地址
string HostName=Dns.GetHostName();
this.textBox1.Text=HostName;
IPHostEntry MyEntry=Dns.GetHostByName(Dns.GetHostName());
IPAddress MyAddress=new IPAddress(MyEntry.AddressList[0].Address);
this.textBox2.Text=MyAddress.ToString();
}
}
}
#9
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection nics = mc.GetInstances();
foreach (ManagementObject nic in nics)
{
if (Convert.ToBoolean(nic["ipEnabled"]) == true)
{
Console.WriteLine((nic["IPAddress"] as String[])[0]);
}
}
ManagementObjectCollection nics = mc.GetInstances();
foreach (ManagementObject nic in nics)
{
if (Convert.ToBoolean(nic["ipEnabled"]) == true)
{
Console.WriteLine((nic["IPAddress"] as String[])[0]);
}
}
#10
winform的我不知道
webform的用
Request.ServerVariables["REMOTE_ADDR"]//客户端IP
webform的用
Request.ServerVariables["REMOTE_ADDR"]//客户端IP
#11
System.Net.IPHostEntry IpEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
for (int i = 0; i != IpEntry.AddressList.Length; i++)
{
if (!IpEntry.AddressList[i].IsIPv6LinkLocal)
{
MessageBox.Show(IpEntry.AddressList[i].ToString());
}
}
for (int i = 0; i != IpEntry.AddressList.Length; i++)
{
if (!IpEntry.AddressList[i].IsIPv6LinkLocal)
{
MessageBox.Show(IpEntry.AddressList[i].ToString());
}
}
#12
学习
#13
牛人
#14
顶……
#15
真的,倒没想过IPV6这个问题,提醒我了
#16
学习
#17
学习
#18
IPAddress.AddressFamily 属性
对于 IPv4,返回 InterNetwork;对于 IPv6,返回 InterNetworkV6。
对于 IPv4,返回 InterNetwork;对于 IPv6,返回 InterNetworkV6。
#19
18楼正解,其他楼层都不对
#20
过来学习
#21
学习了
#22
/// <summary>
/// 获取客户端IP地址
/// </summary>
/// <returns></returns>
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}
else
{
ip = request.UserHostAddress;
}
}
catch (Exception e)
{
throw e;
}
return ip;
}
/// 获取客户端IP地址
/// </summary>
/// <returns></returns>
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}
else
{
ip = request.UserHostAddress;
}
}
catch (Exception e)
{
throw e;
}
return ip;
}
#23
Up
#24
学习了
以前知道4的,没有研究过6的
以前知道4的,没有研究过6的
#25
同意通过AddressFamily 属性判断。
另外,本机ipv4也完全可能是多于1个地址的,不要以为只能有1个。
另外,本机ipv4也完全可能是多于1个地址的,不要以为只能有1个。
#26
#27
学习了
#28
汗,有这么复杂吗
using System.Net;
//方法一:
string strHostIP = "";
IPHostEntry oIPHost = Dns.Resolve(Environment.MachineName);
if (oIPHost.AddressList.Length > 0)
strHostIP = oIPHost.AddressList[0].ToString();
//方法二:
string ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
using System.Net;
//方法一:
string strHostIP = "";
IPHostEntry oIPHost = Dns.Resolve(Environment.MachineName);
if (oIPHost.AddressList.Length > 0)
strHostIP = oIPHost.AddressList[0].ToString();
//方法二:
string ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
#29
IPAddress.getHost()
的一些属性 可以得到
的一些属性 可以得到
#30
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Collections.Specialized;
namespace GetIpv4Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ShowIP();
}
void ShowIP()
{
//ipv4地址也可能不止一个
foreach(string ip in GetLocalIpv4())
{
this.richTextBoxIPv4.AppendText(ip.ToString());
}
return;
}
string[] GetLocalIpv4()
{
//事先不知道ip的个数,数组长度未知,因此用StringCollection储存
IPAddress[] localIPs;
localIPs = Dns.GetHostAddresses(Dns.GetHostName());
StringCollection IpCollection = new StringCollection();
foreach (IPAddress ip in localIPs)
{
//根据AddressFamily判断是否为ipv4,如果是InterNetWork则为ipv6
if (ip.AddressFamily == AddressFamily.InterNetwork)
IpCollection.Add(ip.ToString());
}
string[] IpArray = new string[IpCollection.Count];
IpCollection.CopyTo(IpArray, 0);
return IpArray;
}
}
}
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Collections.Specialized;
namespace GetIpv4Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ShowIP();
}
void ShowIP()
{
//ipv4地址也可能不止一个
foreach(string ip in GetLocalIpv4())
{
this.richTextBoxIPv4.AppendText(ip.ToString());
}
return;
}
string[] GetLocalIpv4()
{
//事先不知道ip的个数,数组长度未知,因此用StringCollection储存
IPAddress[] localIPs;
localIPs = Dns.GetHostAddresses(Dns.GetHostName());
StringCollection IpCollection = new StringCollection();
foreach (IPAddress ip in localIPs)
{
//根据AddressFamily判断是否为ipv4,如果是InterNetWork则为ipv6
if (ip.AddressFamily == AddressFamily.InterNetwork)
IpCollection.Add(ip.ToString());
}
string[] IpArray = new string[IpCollection.Count];
IpCollection.CopyTo(IpArray, 0);
return IpArray;
}
}
}
#31
学习了,楼主加油。
#32
学习了
#33
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
#34
学习………………
#35
mark
#36
路过,学习了~~~~顶顶顶
#37
正解
#38
lai xue xi de
#39
学习了 好东西
#40
楼上的几种方法都行。
#41
Request.ServerVariables["SERVER_NAME"]
呵呵,希望能帮到你!
呵呵,希望能帮到你!
#42
根据计算机名 获取ip地址,下面是代码:
string hostName=Dns.GetHostName();
this.txtName.Text=hostName;
IPHostEntry Entry=Dns.GetHostByName(Dns.GetHostName());
IPAddress pAddress=new IPAddress(Entry.AddressList[0].Address);
this.txtIDAddress.Text=pAddress.ToString();
string hostName=Dns.GetHostName();
this.txtName.Text=hostName;
IPHostEntry Entry=Dns.GetHostByName(Dns.GetHostName());
IPAddress pAddress=new IPAddress(Entry.AddressList[0].Address);
this.txtIDAddress.Text=pAddress.ToString();
#43
dns类
其他的都是上面高手说的!
其他的都是上面高手说的!
#44
来顶顶~
学习了!
学习了!
#45
楼上全有了
#46
运行不起来啊
#47
学习了
#48
路过,学习了~~~~顶顶顶
#49
#50
不知道是调用哪个类。。。
忘记了。。
忘记了。。