Posts

Showing posts from December, 2025

How to use multiple appsettings.json files in .net core webapi project for different environments

Image
Managing configuration is one of the most important parts of any .NET Core application. ASP.NET Core provides a powerful configuration system that allows you to load multiple configuration files, override settings per environment, and keep secrets out of source control. Why Use Multiple AppSettings Files? Advantages 1. Cleaner separation between environments Each environment has its own config file: dev database test API URLs production connection strings 2. No need to modify code during deployment Switch environment → settings automatically apply. 3. Safe and secure deployments Production secrets never appear in development files. 4. Works cleanly with CI/CD & Docker Different settings per environment, same codebase. 5. Supporting reloadOnChange You can update JSON settings without restarting the app (in Development). Disadvantages 1. Requires proper environment variable setup If ASPNETCORE_ENVIRONMENT is not set correctly, the wrong config loads. 2. Mo...