Add geolocation to .NET & find the location of an IP address

Published: 01 July 2024
on channel: Round The Code
924
37

Learn how to add geolocation for free to your .NET project by doing an IPv4 address lookup so you know the country as to where each of your clients are located.

We'll show you how to add it for each of your client's IP address and how you can get the IP address if you are using a reverse proxy like Cloudflare.

As well as that, we'll also show you how you can get city information from your clients.

💻 Download the code example💻
https://www.roundthecode.com/dotnet-c...

► Read the tutorial:
https://www.roundthecode.com/dotnet-t...

🎓 .NET tutorials, code examples and coding challenges 🎓
https://www.roundthecode.com/?utm_sou...

► Chapters
0:00 Coming up...
0:07 Validate the IP address
1:42 Add the geo database
3:37 Perform the IP lookup
5:47 Reverse proxies
7:17 Add the city geo database
10:14 Learn about custom middleware

► Other information
• IP address validation regex: ^(?:1)?(?:\d{1,2}|2(?:[0-4]\d|5[0-5]))\.(?:1)?(?:\d{1,2}|2(?:[0-4]\d|5[0-5]))\.(?:1)?(?:\d{1,2}|2(?:[0-4]\d|5[0-5]))\.(?:1)?(?:\d{1,2}|2(?:[0-4]\d|5[0-5]))$
• Sign up for a MaxMind account: https://www.maxmind.com/en/geolite2/s...


Watch video Add geolocation to .NET & find the location of an IP address online without registration, duration hours minute second in high quality. This video was added by user Round The Code 01 July 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 924 once and liked it 37 people.