.NET 6 – Inject service into program.cs

Using .Net 6 is easy. Just execute GetService method after configure app services and have ran Build method.

WebApplication? app = builder.Build();

var someService = app.Services.GetService<ISomeService>();

someService.DoSomething();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)