I'm creating .net core 3.1 web api application. By default, it is configured to use IHostBuilder
with Startup
file which does some configurations
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
I want to add some configurations into my Startup
file (events producing) and the problem is that they will not be executed on the application startup but only when api receives the first request.
That means that my hosted application won't be able to handle events before it gets a request.
So the question is: How can I invoke configuration methods from the Startup
file on the application start or how can I do specific configuration that will be executed on the application start?