ASP.NET Core Interview Question #27

What is appsettings.json in ASP.NET Core?

Application Structure & Configuration Junior Beginner

Quick Interview Answer

appsettings.json is a standard JSON configuration file used by ASP.NET Core applications. It usually stores non-secret application settings such as logging configuration, connection string names, feature settings, and service options.

Detailed Explanation

appsettings.json is a standard JSON configuration file used by ASP.NET Core applications. It usually stores non-secret application settings such as logging configuration, connection string names, feature settings, and service options.

The file is loaded automatically by WebApplication.CreateBuilder(args). Environment-specific files such as appsettings.Development.json can override its values.

Although connection strings may appear in appsettings.json, production passwords, tokens, and other secrets should normally be supplied through secure configuration providers rather than committed to the repository.

Code Example

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=.;Database=AppDb;Trusted_Connection=True;"
  },
  "ExternalApi": {
    "BaseUrl": "https://api.example.com"
  }
}