Skip to content

'Host.CreateDefaultBuilder' vs 'WebApplication.CreateBuilder' API shape inconsistency #81090

Answered by davidfowl
julealgon asked this question in General
Discussion options

You must be logged in to vote

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 added var builder = Host.CreateApplicationBuilder() as the backbone of WebApplication.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 to WebApplicationBuilder for non-web scenarios:

Web

var builder = WebApplication.CreateBuilder();

builder.Logging.AddConsole();

builder.Services.AddOptions<My…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@julealgon
Comment options

@julealgon
Comment options

@scuba6388
Comment options

@halter73
Comment options

Answer selected by julealgon
Comment options

You must be logged in to vote
1 reply
@mdonatas
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants