0
嗨,我试图让我的本地IP4地址,但结果只返回IIS服务器无法获取本地ip4的地址只有服务器地址
这里的IP是我的代码:
public string GetLocalIPv4(NetworkInterfaceType _type)
{
string output = "";
foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces())
{
if (item.NetworkInterfaceType == _type && item.OperationalStatus == OperationalStatus.Up)
{
foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses)
{
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
{
output = ip.Address.ToString();
}
}
}
}
return output;
}
string IPAddress = GetLocalIPv4(NetworkInterfaceType.Ethernet);
IIS身份验证是我只启用Windows身份验证,因为我使用窗口身份验证。但为什么返回的IP不是我的本地ip4而是IIS服务器地址?
什么是应该返回?什么是返回?你可以添加一些样本的预期和实际数据? –
它应该返回我的本地IP地址而不是我的Web服务器 – samin