Read appsetting.json value
two methods
// method one - read appsetting value by key
public IConfiguration Configuration { get; }
public string ReadAppSetting(string key, string value)
{
// get value via configuration
var section = this.Configuration.GetSection(sectionName);
string result = null;
foreach (var item in section.GetChildren())
{
if (item.Key == key)
{
result = item.Value;
break;
}
}
return result;
}
Last updated
Was this helpful?