• nbolt
  • [ 5.0 , 1 ]
login to rate this
.NET BlogEngine 4.0 [non-official]
0 0
  • nbolt
  • [ 5.0 , 1 ]
login to rate this
[.NET7] Design Patterns: Facade in a Web Application
5 0
  • nbolt
  • [ 5.0 , 1 ]
login to rate this
[.NET7] Design Patterns: Repository in a Web Application
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
[.NET7] IP GeoLocation with Dependency Injection and Custom Middleware
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
[.NET7] Weather Forecast with Dependency Injection and Custom Middleware
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
2 ways for creating QR Code using ASP.NET
0 0
  • nbolt
  • [ 5.0 , 1 ]
login to rate this
AMD Ryzen 9 home server with Fedora 41 and .NET 8
15 1
  • ☺️ 1
    ❤️ 2
    🤩 1
    🫠 1
    😁 3
    😅 2
    😆 2
    😉 1
    😊 1
    😗 1
    😘 1
    😚 1
    🙂 1
    🙃 1
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
ASP.NET MVC Routing with @
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
ASP.NET MVC Routing with Constraints
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
BlogEngine.NET 3.3.5 with a BBQ Sauce
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
BlogEngine.NET 3.3.5 with a BBQ Sauce: Part 2
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
EF7 on .NET Core 7 (Preview): Fedora 35 x Windows 11 (41 Million Rows)
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Entity Framework Core 6: Fedora 35 x Windows 11 (41 Million Rows)
0 0
  • nbolt
  • [ 5.0 , 1 ]
login to rate this
Entity Framework Core 7 (Preview): Fedora 35 x Windows 11 (41 Million Rows)
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Entity Framework Providers for the .NET BlogEngine
0 0
  • nbolt
  • [ 5.0 , 1 ]
login to rate this
Enum as String in EF Core
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Facebook: Data Deletion Callback URL in C#
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
How to fix the Could not load file or assembly 'System.IO.Compression' or one of its dependencies exception
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
How to Recover Access to your Account in an ASP.NET Application using the Membership (without decrypting your password)
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Installing and Configuring Jenkins with GIT to Build and Deploy Your .NET Application
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Installing and Configuring Jenkins with SVN to Build and Deploy Your .NET Application
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
IP GeoLocation with Unity and Dependency Injection
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
NHibernate Providers for the .NET BlogEngine
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
No mercy for the ORMs: Load and Performance Test on EF Core, NHibernate and pure ADO.NET (41M rows)
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Resizing images on a Controller Method in ASP.NET Core (.NET 6)
0 0
  • 🔥 1
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Streaming Video Files in ASP.NET MVC
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Testing your MVC App on XSP/mono in Fedora (before deploying to Apache)
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Weather with Unity and Dependency Injection
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
[.NET7] Weather Forecast with Dependency Injection and Custom Middleware
0 0

Hi Folks! In this post I will show you how to retrieve the user's weather forecast information from their IP address in a .NET7 application, using dependency injections and a custom middleware. The IP GeoLocation service layer in the sample application will be responsible for retrieving the user's physical location (and that's why you need to register yourself on IpInfoDb to get an API key). Then the Weather Forecast service layer with the location in hand will lookup for the user's weather forecast information (again, you will need to sign up for an API key on OpenWeatherMap).

Clone the github repository here. But don't forget to checkout a branch called weather.

There's currently 2 weather providers in the solution: ForecastIO and OpenWeatherMap. If you decide to also take advantage of using ForecastIO, you will need to go to their website and register yourself for an API key.

This application follows the same logic as the one in [.NET7] IP GeoLocation with Dependency Injection and Custom Middleware. It registers a middleware called WeatherMiddleware that will be responsible for choosing the best instance of the weather service and then retrieving the weather information.

Open the NET7-IPGeolocation.sln solution file and head to the Services.WeatherForecast project. You should see a class called Concrete/OpenWeatherMap.

Well, the best way to understand the application would be to run it (after getting the API keys, of course). Put a breakpoint in the Forecast method of the concrete classes inside the Services.WeatherForecast project, and another one at the weather middleware (InvokeAsync method).

You should see an output like this one (your location and weather):

Feel free to ask any questions you might have in the comment section below, I will do my best to answer them.

Hope you guys enjoyed it. See ya!

what to see next
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
[.NET7] IP GeoLocation with Dependency Injection and Custom Middleware
0 0
  • nbolt
  • [ 0.0 , 0 ]
login to rate this
Weather with Unity and Dependency Injection
0 0
  • nbolt
  • [ 5.0 , 1 ]
login to rate this
[.NET7] Design Patterns: Facade in a Web Application
5 1
comment section
place your comment here, but login first
be the first to comment
An error has occurred . This application may no longer respond until reloaded . An unhandled exception has occurred . See browser dev tools for details . Reload 🗙