.Net 6 Console app: WebApplication.CreateBuilder vs Host.CreateDefaultBuilder

WebApplication.CreateBuilderpart() is only used for web/api applications like the name implies Host.CreateDefaultBuilder() is used to build a generic host (without web services, middleware etc) which you can use to build anything other than webhost.

See for example;
https://learn.microsoft.com/en-us/dotnet/core/extensions/generic-host
Which has not changed.

Its true that it feels a bit awkward to build console apps and/or backgroundservices at the moment.

Leave a Comment