-
Ever since "generic host" became a thing, the This design feels very disconnected: each of these 2 "builders" have different ways of configuring logging, services, etc: one uses configuration methods (the generic host), while the AspNet version relies on properties to expose the underlying builders. Why have the teams not aligned on this and built a unified interface for hosting that also works for AspNetCore in a seamless way? Are there any discussions to eventually unify this and have project setup be consistent no matter the target use case? Why is the It makes no sense to me that if I have a Worker process where I then want to add HTTP API capabilities to, I'm forced to basically rewrite my entire setup code due to the shift from I see this is called "minimal hosting" from here: But why would it be specific to AspNetCore though... why not modify Hosting.Extensions itself to be "minimal by default" then? @davidfowl would like to hear your thoughts on this since you were the one proposing the minimal hosting effort. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
We moved away from the ceremony of a generic host in the default templates and to the scenario specific Web var builder = WebApplication.CreateBuilder();
builder.Logging.AddConsole();
builder.Services.AddOptions<MyOptions>().BindConfiguration("MyConfig");
builder.Services.AddHostedService<MyWorker>();
var app = builder.Build();
app.MapGet("/", () => "Hello World");
app.Run(); Non-Web var builder = Host.CreateApplicationBuilder();
builder.Logging.AddConsole();
builder.Services.AddOptions<MyOptions>().BindConfiguration("MyConfig");
builder.Services.AddHostedService<MyWorker>();
var host = builder.Build();
host.Run(); The plan is the switch everything to this style, but the new hosting APIs in the generic host are missing the |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
We moved away from the ceremony of a generic host in the default templates and to the scenario specific
WebApplicationBuilder
. The general idea was to move away from calbacks and move to linear code for configuring everything, this was part of .NET 6. In .NET 7, we addedvar builder = Host.CreateApplicationBuilder()
as the backbone ofWebApplication.CreateBuilder
so we could have a smoother integration of the API styles (building the linear API on top of the callback API was error prone). As a result, we now have a similar pattern toWebApplicationBuilder
for non-web scenarios:Web