美文网首页
net core 获取服务器IP地址

net core 获取服务器IP地址

作者: 灰纸黑字 | 来源:发表于2019-07-24 17:50 被阅读0次

string aa = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()

    .Select(p => p.GetIPProperties())

    .SelectMany(p => p.UnicastAddresses)

    .Where(p => p.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork && !System.Net.IPAddress.IsLoopback(p.Address))

    .FirstOrDefault()?.Address.ToString();

相关文章

网友评论

      本文标题:net core 获取服务器IP地址

      本文链接:https://www.haomeiwen.com/subject/wxsfrctx.html