Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

I'm looking into .NET 6, and wanted to build a simple console application, with some dependency injection.

From what i can read, a lot has been done to make the startup (now just program) file, more readable. What does confuse me a bit is, that all improvements seems to have been made to WebApplication.CreateBuilderpart used in API projects, and not the Host.CreateDefaultBuilder. As mentioned in this blog

Microsofts own docs, also only seems to mention WebApplication.

To me it seems like WebApplication is only for web projects, like an API, and i can't find anything that confirms og debunks that.

Is it okay to use WebApplication in a console application, or should i rely on Host, and keep the stacked lambda expressions ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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://docs.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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!