Detect/estimate country of a http-request in ASP.NET

后端 未结 5 2257
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 10:15

I\'m looking for ways to detect/estimate the country from which a http-request is coming in ASP.NET.
I know there are

5条回答
  •  时光取名叫无心
    2020-12-14 11:11

    You can make a simple HTTP request to this URL:

    http://api.hostip.info/get_html.php?ip=207.46.197.32
    

    using the value of the REMOTE_ADDR server variable. That will return the country and city like this:

    Country: UNITED STATES (US)
    City: New York, NY
    

    I use that service for a web form just as you describe. Occasionally it doesn't know the answer, but usually it's very good (and it's free and simple 8-)

    In C#, you can use System.Net.WebRequest.Create to read from the URL.

提交回复
热议问题