Module-based web app: Custom startup pipeline not supported #26734
Replies: 3 comments 1 reply
-
The basic problem here is that while multiple calls to ConfigureServices are supported, only one call to Configure is supported. Services are much less order sensitive, but Configure is responsible for building an order sensitive pipeline. Your best approach was probably:
The MVC errors don't seem to be an issue with your approach, only that you're missing some services that need to be registered. Admittedly IWebModule can't register additional services. The only module system designed for that is HostingStartup. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/platform-specific-configuration?view=aspnetcore-3.1 |
Beta Was this translation helpful? Give feedback.
-
Thank you. I wasn't aware of I'm not really trying to call What I kinda fail to understand is why my modules technically can't register additional services. I know, the service provider is already built when I would resolve them, so that doesn't make much sense, however when browsing through the AspNetCore hosting code (especially the My MVC errors directly relate to that issue. The exception occurs when I try to resolve my modules from
But I feel like something like that just isn't possible? |
Beta Was this translation helpful? Give feedback.
-
Orchard supports this natively, I'd recommend starting there |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In order to better separate application concerns I tried to introduce a module-based approach for configuring the web-host and the application pipeline, however I am failing to understand what "magic conventions" or restrictions are at work within mostly Microsoft.AspNetCore.Hosting since nothing I try seems to work.
I created a new interface like this:
At first I included the following into a custom convention-based startup:
This obviously didn't work since there is no real
IServiceProvider
yet available. It seems there is only a pseudo-service locator within GenericWebHostBuilder.Instead of relying on
WebHostBuilder.UseStartup<T>()
, I then tried to utilizeWebHostBuilder.Configure(Action<IApplicationBuilder>)
and call the following:While just calling
builder.Configure()
works, this one then throws exception such as:InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RuntimeViewCompilerProvider'.
Next I tried again with a custom startup implementing
IStartup,
but resolving services beforehand.Which then results in a
NotSupportedException
telling thatIStartup
isn't supported.Last I did was trying to create my own
Configure()
-Extension, but that didn't work either, sinceConfigure
seems to internally cast theIWebHostBuilder
toISupportsStartup
, which is internal.Is there a better approach to accomplish this? Or did I completely misunderstand something here? @davidfowl @Tratcher
Beta Was this translation helpful? Give feedback.
All reactions