1

I'm writing a web app in asp.net core mvc and I need to find current location- at least on city level how do I do this? is there a Nuget package I could install or something? because the .net library that supports this is only in .net framework

aluf
  • 31
  • 2
  • Are you looking to perform IP geolocation from the server, or use the location API on the client? – David Sep 28 '22 at 15:32

1 Answers1

2

You could use a service like ip-api.com.

here is the documentation for retrieving user location data by ip adress where with a json response: https://ip-api.com/docs/api:json

simply get the users ip adress in the controller like shown here and call their api with the users ip. ex. http://ip-api.com/json/24.48.0.1

A-New-User
  • 61
  • 3
  • Nice to see you've recently picked up answering questions. Please read [answer] and don't answer off-topic questions. Asking for off-site resources is considered to be off-topic, as they tend to attract spam. What is so special about this particular service you're recommending? Why not one of the dozens of other services that provide the same functionality? – CodeCaster Sep 28 '22 at 16:07
  • Hi! I m new to this, so thanks for the feedback in the first place :) its true that their are dozens of other services that provide the same functionality. i just stumbled upon this one and deemed it worth recommending since it does not require any kind of credentials, login or activation key and is free for non commercial use. other services would also be a viable choices. – A-New-User Sep 28 '22 at 16:20