Default Configuration Providers In ASP.NET Core Application

One of the extremely powerful features of .Net Core is Configuration provider, which allows reading configuration data as key-value pairs from various sources like Azure Key Vault, directory files, Azure app configuration, and environment variables, to name but a few. Whenever we create a web application in .Net core, there are 5 default configuration providers that are loaded by the static method CreateDefaultBuilder () of Host Class at runtime.
  1. public static IHostBuilder CreateHostBuilder(string[] args) =>  
  2.               Host.CreateDefaultBuilder(args)  
You can verify it, by putting a breakpoint in the constructor of the Startup class.
 Default Configuration Providers In ASP.NET Core Application 
We can get detailed information about each by writing a line of code in a method (e.g.: OnGet()) of a class (e.g: IndexModel.cshtml.cs).
  1. IEnumerable<IConfigurationProvider> configurationProviders = ((ConfigurationRoot)_configuration).Providers;  
 For brevity and to keep the HTML table visible, I have removed fully qualified namespaces from the right-side column from below the image.
Default Configuration Providers In ASP.NET Core Application
In the above image, there are 6 providers to distinguish from the default 5 providers, so I enabled the secret management feature of .Net core for this demo application. So, the total number of providers can vary based on your application configurations.
Built-in configuration providers read configuration data from. json/.xml file, environment variables, and command-line arguments.
All the concrete providers like jsonconfigurationprovider, commandlineconfiugrationprover etc, inherit from abstract class ConfigurationProvider which implements interface IConfigurationProvider.
Below is the code to generate the above HTML table
  1. <table border="1" style="border:1px solid black;">    
  2.     @{    
  3.         int configProviderCounter = 0;    
  5.     }    
  6.     <tr>    
  7.         <td> No </td>    
  8.         <td>File Name</td>    
  9.         <td> <b>Concrete Class</b> </td>    
  10.     </tr>    
  11.     @foreach (IConfigurationProvider configProvider in Model.ConfigProviders)    
  12.     {    
  13.         configProviderCounter = configProviderCounter + 1;    
  14.         <tr>    
  15.             <td>@configProviderCounter</td>    
  16.             <td> @configProvider.ToString() </td>    
  17.             <td> @configProvider.GetType().ToString().Substring(configProvider.GetType().ToString().LastIndexOf(".") + 1) </td>    
  18.         </tr>    
  20.     }    
  21. </table>     
I hope you found this information very helpful.