I have an appsettings.json and appsettings.Development.json. I need to assign the SmtpServer name depending on the environment.
The config file in appsettings.json is:
{
"EmailConfiguration": {
"SmtpServer": "mail.MYDOMAIN.com"
}
}
And in appsettings.Development.json is:
{
"EmailConfiguration": {
"SmtpServer": "mail.MYLOCAL.com"
}
}
When I assign the configuration in Startup ConfigureServices() like such:
var emailconfig = Configuration.GetSection("EmailConfiguration").Get<EmailConfiguration>();
services.AddSingleton<IEmailConfiguration>(emailconfig);
It always uses appsettings.json ('mail.MYDOMAIN.com') and NOT appsettings.Development.json.
How do I modify this code to use the correct environment settings?