I have a project class (Nuget Package). I need to read in a static class without constructor my connections string to MongoDB.
Static Class Method:
Something like this should work:
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath).AddJsonFile("config.json");
Configuration = builder.Build();
var connStr = Configuration.Get("connString");
}
Docs: http://docs.asp.net/en/latest/fundamentals/configuration.html