1
我試圖將一個id列表綁定到一個設置,並且它在我使用綁定時起作用,但是使用GetValue檢索它不起作用。即這個工程:.Net Core 2.0配置與列表
var authenticationSettings = new Authentication();
this.Configuration.GetSection("Authentication").Bind(authenticationSettings);
var clients = authenticationSettings.AuthorizedApplications;
這不:
var authenticationSettings = this.Configuration.GetValue<Authentication>("Authentication");
這不起作用
var clients = this.Configuration.GetValue<List<string>>("Authentication:AuthorizedApplications");
這裏是我的配置類:
public class Authentication
{
public List<string> AuthorizedApplications { get; set; }
}
這是不必要的。只需使用'Configuration.GetSection(「SectionName」)。獲取();' –