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 appsettings.json
file
like _config = ActivatorUtilities.CreateInstance<IConfiguration>(null);
System.InvalidOperationException: 'A suitable constructor for type 'Microsoft.Extensions.Configuration.IConfiguration' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.'
It makes sense because it is interface, but how it does work in Controller's Constructor case? and how can I create an instance of that?
I'm using MS DI
Thanks
You can create a local instance of configuration as shown below.
For further information see Configuration in ASP.NET Core