Access to configuration without dependency injection

后端 未结 3 1206
予麋鹿
予麋鹿 2020-12-29 01:51

I was wondering if there was a way to access Configuration (Microsoft.Extensions.Configuration) without the use of dependency injection. Only examples I see are through con

3条回答
  •  感情败类
    2020-12-29 02:45

    I just made the config property in Startup static:

    public static IConfiguration Configuration { get; set; }
    

    Now I can access it anywhere in the application with just Startup.Configuration.

提交回复
热议问题