Configure multiple hosts at runtime #28228
-
Hello, I start with the main host using hostbuilder, where i setup services and start listening for tcp connections All these hosts should share the same IServiceProvider because some components are singletons and some of the singletons are Open generics registration and as I discovered currently there is no way to create kind of child serviceproviders that share the same open generic singletons. So I'd like to understand how can I start multiple hosts doing different things on different ports. If a single host can implement web api (controllers) on different ports using a single kestrel instance, and thus a single Host, I could adapt my code to that, so please tell me even if this last scenario is possible. What are the alternatives? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
One host maps to one service provider and while it may be possible to hack that, it's an assumption baked into the host (especially since ConfigureServices is a first class method on the IHostBuilder).
Yes you can listen to multiple ports and have controllers (or any endpoint really) only be valid for a particular host. |
Beta Was this translation helpful? Give feedback.
One host maps to one service provider and while it may be possible to hack that, it's an assumption baked into the host (especially since ConfigureServices is a first class method on the IHostBuilder).
Yes you can listen to multiple ports and have controllers (or any endpoint really) only be valid for a particular host.