我们有一些遗留的4.5.2类库,常用
如果我将问题的
例如:
ConfigurationManager.AppSettings[key]
。
是否可以在 .net core 2 应用程序中引用它们,以便在幕后正确地修补配置?也就是说,旧的调用到ConfigurationManager.AppSettings[key]
在 .netcore2 应用程序中正确读取配置,无论是来自于json还是xml。如果我将问题的
keys
移植到appSettings.json中,那么对ConfigurationManager.AppSettings
的调用总是返回null。例如:
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
},
"appSettings": {"test": "bo"},
"test": "hi"
}
然后:
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2", ConfigurationManager.AppSettings["test"] , ConfigurationManager.AppSettings["appSettings:test"] };
}
会显示:
["value1","value2",null,null]