How can I create an instance of IConfiguration locally?

后端 未结 1 1814
广开言路
广开言路 2021-01-21 03:52

I\'d want to ask how to create an instance of ASP.NET Core\'s Configuration, the same that\'s being created when I require it in Controller\'s constructor which knows about the

相关标签:
1条回答
  • 2021-01-21 04:14

    You can create a local instance of configuration as shown below.

    IConfigurationRoot configuration = new ConfigurationBuilder()
                .SetBasePath([PATH_WHERE_appsettings.json_RESIDES])
                .AddJsonFile("appsettings.json")
                .Build();
    

    For further information see Configuration in ASP.NET Core

    0 讨论(0)
提交回复
热议问题