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