Hi, @Angela_HAC. Welcome to Microsoft Q&A.
If you cannot adjust the constructor parameters and cannot perform dependency injection, you could consider setting IConfiguration
as a static property for global access.
Create a static class
public static class GlobalConfiguration
{
public static IConfiguration? Configuration { get; set; }
}
Assign value in Program
or Startup
GlobalConfiguration.Configuration = app.Services.GetService<IConfiguration>();
Get IConfiguration
where needed
var _configuration = GlobalConfiguration.Configuration;
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.