I want to use single config file in my ASP.NET project files.
Is there a normal adequate way to stop using default ASP.NET configuration files (e.g. launchSettings.json, appSettings.json...) and apply their settings by my own settings file?
I can't find any settings for these files in empty project.
For newbie in C# I can see these files behind the scene:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.Run();
launchSettings.json
is used only for development environments and is quite useful for this case since it provides ability to setup additional things, not only configuration (see Development and launchSettings.json
section of docs).
You can easily clean the configuration sources included by default and add your own:
builder.Configuration.Sources.Clear();
builder.Configuration.AddJsonFile("myConfig.json");
Personally I would recommend to stick to the idiomatic approach provided by the framework which will adhere to principle of least astonishment