ASP.NET(C#)中怎样获取用户的IP地址跟网卡号

来源:百度知道 编辑:UC知道 时间:2024/05/18 00:08:27
网卡号就是物理地址

NetworkInterface[] NetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface NetworkIntf in NetworkInterfaces)
{
IPInterfaceProperties IPInterfaceProperties = NetworkIntf.GetIPProperties();
UnicastIPAddressInformationCollection UnicastIPAddressInformationCollection = IPInterfaceProperties.UnicastAddresses;
foreach (UnicastIPAddressInformation UnicastIPAddressInformation in UnicastIPAddressInformationCollection)
{
if (UnicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork)
{
Console.WriteLine(UnicastIPAddressInformation.Address);
}
}
}

string strIPAddress = Request.UserHostAddress;
网卡什么号获得不了.

string s = Request.UserHostAddress;

Request.UserHostAddress