I have 2 applications
- App
- ClassLibrary
App references ClassLibrary and both have their own appsettings.json file. My class library app has no startup.cs or program.cs so I have a static class that is supposed to read from the local appsettings.json file like this:
static class ConfigurationManager
{
public static IConfiguration AppSetting { get; }
static ConfigurationManager()
{
AppSetting = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
}
}
This is the appsettings.json in the class library
{
"AccountsAddress": "http://localhost:55260/api/Accounts/"
}
The problem starts when my app runs, it calls a method located in class library. However, the appsettings that is called is not the one in class library. Its the one in the app itself. Is there a way to specify that I want to reference the appsettings in the class library instead of the App.