通过IP地址获取用户位置
问题描述:
我用C#编写的ASP.NET网站。
I have an ASP.NET website written in C#.
在这个网站,我需要自动显示根据用户的位置开始页面。
On this site I need to automatically show a start page based on the user's location.
我可以根据用户的IP地址,用户所在城市的名字?
Can I get name of user's city based on the IP address of the user ?
答
您需要一个基于IP地址反向地理编码API ...喜欢的一个从hostip.info 。我敢肯定有很多可供选择。
You need an IP-address-based reverse geocoding API... like the one from hostip.info. I'm sure there are plenty of options available.
您可能希望允许用户覆盖这一点,但是。例如,他们可以在一个企业的VPN,这使得IP地址的看的就像是在不同的国家。
You may want to allow the user to override this, however. For example, they could be on a corporate VPN which makes the IP address look like it's in a different country.