Having trouble reading data from appsettings.json in a .netcore 2.0 console app looked at a bunch of examples syntax is not working/ any suggestions? the value in my appsettings.json looks like this "OBNAME": { "OBKEY": "OBKPASS"
}
I basically want to assign the OBNAME values to a var in another class
public const string ConfigurationFileName = "appsettings.json";
public static YourClass CreateConfiguration()
{
var builder = new ConfigurationBuilder()
.AddJsonFile(ConfigurationFileName);
IConfigurationRoot configurationRoot = builder.Build();
YourClass yourClass = new YourClass();
configurationRoot.Bind(yourClass );
return filePolicyConfiguration;
}
In YourClass
put the properties like the appSettings.json built, put OBNAME
as property int this class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.