I have created a couple of these .net core 2 web app and no issue until this one.
Running local under IISExpress it runs correctly but when I deploy a debug version to an IIS folder on the server I have issues.
When I read the config entry it is not found:
_config["MySettings:MyName"];
files contents:
appsettings.Development.json
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Trace",
"System": "Information",
"Microsoft": "Information"
}
},
"MySettings": {
"MyName": "JohnDoe"
}
}
appsettings.json
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Trace"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}
launchSetting.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60668/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/security",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApi.ViewerSecurity": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/security",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:60669/"
}
}
}
If I copy appsettings.Development.json and rename to appsettings.Production.json it works.
I changed the value of "MyName" in the prod file and logged it. Yup, reading from appsettings.Production.json.
How and why? Production isn't defined anywhere.