ASP.NET Core Interview Question #219

How should configuration differ between development and production?

Testing, Deployment & Hosting Senior Advanced

Quick Interview Answer

Configuration should vary by environment without changing application code. Development may use local databases, verbose diagnostics, developer exception pages, and local secret storage. Production normally uses protected secrets, controlled log levels, production endpoints, HTTPS, and safe error handling.

Detailed Explanation

Configuration should vary by environment without changing application code. Development may use local databases, verbose diagnostics, developer exception pages, and local secret storage. Production normally uses protected secrets, controlled log levels, production endpoints, HTTPS, and safe error handling.

ASP.NET Core configuration can combine appsettings files, environment variables, command-line values, and external configuration or secret stores.

Sensitive production values should not be committed to appsettings files in source control.

Code Example

if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}
else
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}