What is the difference between Host and WebHost class in asp.net core

The difference one could see in .NET Core 3.0 vs .NET core 2.2 code is that .NET core 3.0 uses the Generic Host while .NET Core 2.2 use the Web Host for web application. The Generic host got included with ASP.NET CORE 2.1 and became the de-facto standard for the future version of .NET Core. Though the Generic host got included in .NET core 2.1 it was only used for non HTTP workloads. In.NET Core 3.0 it became a universal standard (HTTP + non HTTP workloads).

The reason for shifting from WebHost builder to more generic Host builder is because the WebHost builder was tied more to HTTP request and works well for Web application but with the advent of Microservices and Docker it felt the need of a more generic Web host so .NET Core team revamped it, making it usable with console application also. With Generic Host it is possible to utilize the logging, configuration, and DI libraries within a console application.

To create a Host we can use the new HostBuilder, which has a similar set of methods and extensions as the existing WebHostBuilder.There is one main difference to be aware of and that is HostBuilder doesn’t provide an extension method that allows you to use a startup class as we can with the WebHostBuilder. This decision was made primarily to avoid the need to create two separate DI containers behind the scenes. With the generic host, a single service collection is configured and then used to build the final service provider.

Reason to use ConfigureWebHostDefaults is that the new host builder is a Generic Host Builder so it is important to tell that we intend to configure the default settings for a Web Host.

Please refer to the Microsoft reference which recommends using Generic Host here