There is no Startup.cs in the web/api application any more.
We used to be able to inject IConfiguration into that Startup class.
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration
}
...
}
Now that those add service and configuration code is moved into Program.cs, what is the correct way to access configuration from there?
The IConfiguration can be accessed in the WebApplicationBuilder.

So no need to inject IConfiguration any more, it is now a property in the builder in Program.cs.

var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
builder.Services.AddInfrastructureServices(config);
builder.Services.AddPersistenceServices(config);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With