受欢迎的博客标签

1.ASP.NET Core Configuration can come from various sources as follows:

ASP.NET Core Configuration can obtain some values from various sources.  we can use and combine various sources for configuration settings (values): Files (JSON, XML, INI) Command-line arguments Environment variables In-memory .NET objects Azure Key Vault     

One of default sources is appsettings.json file that comes with ASP.NET Core 2 templates.It is  key-value pairs collection.     You can also create custom providers and plug them into the ASP.NET Core system.  

2.override values ordering is as follows:

Memory configuration source JSON configuration source (appsettings.json) JSON configuration source (appsettings.Development.json) Environment variables configuration source Command line arguments configuration source  

That means that if use default app configuration anything in appsettings.{Environment}.json will override values from appsettings.json. Environment variables will override memory and appsettings.json/appsettings.{Environment}.json configuration. At the end, command line arguments will override any of these, since they come in last.

3.How to Remove default configuration options builder.Sources.Clear() will removes everything that is currently set in Configuration (Env variables, appsettings.json, in memory configs etc).  

  public static IWebHost BuildWebHost(string[] args)

{

return WebHost .CreateDefaultBuilder(args)

.ConfigureAppConfiguration( (WebHostBuilderContext context, IConfigurationBuilder builder) =>

{ builder.Sources.Clear(); }) .UseStartup() .Build(); } .