Open utterances-bot opened 2 years ago
Thank you for this article. Saved a lot of time for me.
I have one question.
In my project, I am using appsetting.json
and have wired that up with ConfigurationBuilder().AddJsonFile("appsettings.json")
but I also need to access some of its variables in my startup class itself to configure my app with some authentication.
How can I access configuration values in my startup class?
Integrating ASP.NET Core Configuration in MVC 4 - Scott Dorman
ASP.NET Core 1.0 (what had been called ASP.NET 5) is a complete redesign of ASP.NET that is open-source and cross-platform. Since this is a redesign of the framework, it comes with a lot of architectural changes that make it more modular. One of those changes is that environment-based configuration is now built-in. The biggest benefit of this new configuration system is that it’s not based on System.Configuration or web.config. Instead, it pulls from an ordered set of configuration providers that support a variety of file formats (such as XML and JSON) as well as environment variables. If one of the built-in configuration providers doesn’t meet your needs, you can write your own.
https://scottdorman.blog/2016/03/19/integrating-asp-net-core-configuration-in-mvc-4/