Last active
May 13, 2018 10:40
-
-
Save jesuscampos/c339330c23c04c05ec1fe0f7723055ed to your computer and use it in GitHub Desktop.
Configuration builder
This file contains hidden or 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
// Si hemos usado CreateDefaultBuilder en la configuración del Host | |
// tendremos la opción de recibirla por inyección en el constructor | |
public Startup(IHostingEnvironment env, IConfiguration configuration) | |
{ | |
HostingEnvironment = env; | |
Configuration = configuration; | |
} | |
// Si no hemos usado CreateDefaultBuilder en la configuración del Host | |
// deberemos registrar la configuración en el Startup | |
public Startup(IHostingEnvironment env) | |
{ | |
var builder = new ConfigurationBuilder() | |
.SetBasePath(env.ContentRootPath) | |
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) | |
.AddEnvironmentVariables(); | |
Configuration = builder.Build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment