当我访问我的网页时,为什么我会得到本地用户的IP地址?
我正在尝试从我的网站获取访问用户的IP地址。我能够获得自己的IIS服务器IP地址;但是,这不是我需要的。我正在寻找用户的IP地址。具体来说,我正在寻找由a
我设法在视图上使用了此代码来获取自己的ISP IIS服务器IP
@using System
@using System.Text
@using System.Net
@using System.Net.Sockets
@{
string myIP = string.Empty;
IPHostEntry heserver = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress curAdd in heserver.AddressList)
{
if (curAdd.AddressFamily.ToString() == ProtocolFamily.InterNetwork.ToString())
myIP += curAdd + " ";
}
}
。如何查询.NET 6.0 Web应用程序上访问用户的IP地址?
I am trying to get the visiting user's IP address from my Web site. I was able to get my own IIS Server IP address(es); however, that is not what I need. I am looking for the User's IP address. Specifically, I am looking for the IP address that is generated by a https://whatismyipaddress.com/ access.
I have managed to get my own ISP IIS Server IP with this code on my View.cshtml:
@using System
@using System.Text
@using System.Net
@using System.Net.Sockets
@{
string myIP = string.Empty;
IPHostEntry heserver = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress curAdd in heserver.AddressList)
{
if (curAdd.AddressFamily.ToString() == ProtocolFamily.InterNetwork.ToString())
myIP += curAdd + " ";
}
}
In the case above, myIP depicts my own IIS IP addresses. How do I query for the Visiting user's IP address on my .NET 6.0 Web application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论