Get user location by IP address

前端 未结 14 1241
深忆病人
深忆病人 2020-11-28 02:23

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.

Can I get name of user\'s city

14条回答
  •  迷失自我
    2020-11-28 02:46

    IPInfoDB has an API that you can call in order to find a location based on an IP address.

    For "City Precision", you call it like this (you'll need to register to get a free API key):

     http://api.ipinfodb.com/v2/ip_query.php?key=&ip=74.125.45.100&timezone=false
    

    Here's an example in both VB and C# that shows how to call the API.

提交回复
热议问题