What is Generic Host in .NET Core?
What is Generic Host in .NET Core?
In .NET Core, the Generic Host is a hosting mechanism provided by the Microsoft.Extensions.Hosting
namespace. It is designed to simplify the process of building and configuring applications, particularly for services like console applications, Windows services, and ASP.NET Core applications. The Generic Host is built on top of the ASP.NET Core hosting infrastructure and provides a consistent way to configure and run applications regardless of the application type[1][2].
Encapsulation of Common Application Concerns:
appsettings.json
[2][5].Flexibility and Consistency:
The host is typically configured, built, and run by code in the Program.cs
file. Here is an example of how to create and run a Generic Host:
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(arg...
junior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào