We have some legacy 4.5.2 class libraries that make common use of ConfigurationManager.AppSettings[key]
Is it possible to reference these within a .net core 2 application so that the config is correctly patched up under the hood?
I.e. the old calls into ConfigurationManager.AppSettings[key]
correctly read the config, either from json or xml, but within the .netcore2 app.
If I port the keys
of question to appSettings.json then the call into ConfigurationManager.AppSettings
always returns null.
An example would be:
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
},
"appSettings": {"test": "bo"},
"test": "hi"
}
And then:
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2", ConfigurationManager.AppSettings["test"] , ConfigurationManager.AppSettings["appSettings:test"] };
}
Will display:
["value1","value2",null,null]