I need to add a couple of pending functions to ConfigureServices in Startup.cs, and I ran into a problem.
System.InvalidOperationException Could not find the required services. Please add all the necessary services by calling "IServiceCollection.AddMvc ()" inside the call to "IApplicationBuilder.ConfigureServices (...)" or "IApplicationBuilder.UseMvc (...)" in the application’s startup code.
As you can see from the code below, AddMvc and UseMvc are in the right place, however, I still get this error.
public async void ConfigureServices(IServiceCollection services) { ... await manager.Initialize(); var data = await manager.GetData(); ... services.AddMvc(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory loggerFactory) { ... app.UseMvc(); .... }
Can I configure the ConfigigureServices async function?
Brian
source share