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...