Created
April 30, 2021 15:33
-
-
Save manoj-choudhari-git/08ed5148ee89b957b5ac5dba112f177c to your computer and use it in GitHub Desktop.
C# .NET - Host Configuration vs App Configurations - Difference and similarities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
CreateHostBuilder(args).Build().Run(); | |
} | |
private static IHostBuilder CreateHostBuilder(string[] args) | |
{ | |
return Host.CreateDefaultBuilder(args) | |
.ConfigureHostConfiguration(configHost => | |
{ | |
configHost.SetBasePath(Directory.GetCurrentDirectory()); | |
configHost.AddJsonFile("hostsettings.json", optional: true); | |
configHost.AddEnvironmentVariables(prefix: "MYDEMOAPP_"); | |
configHost.AddCommandLine(args); | |
}) | |
.ConfigureAppConfiguration(app => | |
{ | |
app.AddJsonFile("appsettings.json"); ; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment