A simple ASP.NET Core MVC application that fetches weather data from OpenWeatherMap API.
Note: Currently, the API returns raw responses or deserialized JSON directly from the service. HTML view rendering is planned for future implementation.
- Fetch weather data in JSON or XML format.
- View raw API responses.
- Deserialized weather info is available via the service (no controller/view yet; HTML rendering planned for future).
- .NET 8 SDK
- OpenWeatherMap API Key (https://openweathermap.org/api)
- Visual Studio 2022 / VS Code or any compatible IDE
- Clone the repository
git clone https://github.com/<YOUR_GITHUB_USERNAME>/SimpleWeatherApp.git
cd SimpleWeatherApp- Set your API key
Open appsettings.json and replace the placeholder with your OpenWeatherMap API key:
{
"WeatherApiOptions": {
"ApiKey": "<YOUR API KEY HERE>"
}
}- Restore packages
dotnet restore- Run the application
dotnet runBy default, the application will run at:
https://localhost:7152
http://localhost:5000
You can call the service directly in your code:
var weather = await weatherService.GetWeatherAsync("Manila", "json");Currently, no controller returns the deserialized object. HTML view rendering is planned for future implementation.
You can access raw API responses through the existing controller:
- JSON:
/weather?city=Manila&format=json - XML:
/weather?city=Manila&format=xml
- Strategy pattern selects the appropriate deserializer for JSON or XML.
HttpClientFactoryis used for efficient HTTP requests.- Logging via
ILoggertracks API calls and errors. - HTML view rendering is planned for future implementation; currently, deserialized data is only available in the service layer.
This project is licensed under the MIT License.