Configuring Application Configuration in ASP.NET Core 2

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

Configuration of asp.net core seems to be particularly moved from startup.cs in program.cs. Here is one example:

public class Program
    {
       
public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

       
public static IWebHost BuildWebHost(string
[] args) =>
           
WebHost
.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((ctx, cfgBuilder) =>
            {
                cfgBuilder.
                 AddJsonFile(
"appsettings.json", optional: false, reloadOnChange: true
)
                .AddJsonFile(
$"appsettings.{ctx.HostingEnvironment.EnvironmentName}.json"
                 optional:
true
)
                .AddEnvironmentVariables();
            })
                .UseStartup<
Startup
>()
                .Build();
    }



Posted Jul 16 2017, 10:16 AM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.