What exactly is the ASP.NET Core 5 host?

Viewed 80

After the build, inside the bin folder, there are 2 main files {AppName}.exe and {AppName}.dll, what I understand is AppName.dll is the actual compiled application code and AppName.exe is the host which hosts the app inside Kestrel.

My question: is this .exe due to the Program.cs, and is it the one that acts as a worker process under which our application runs because we get the process name as application name for ASP.NET Core 5 and not dotnet (dotnet.exe) anymore.

1 Answers

AppName.exe is not the host. The exe is an executable that can be used to run the application, if the project type is an executable targeting .NET Core 3.0 or later. More about details you can refer to dotnet build command.

The ASP.NET Core project templates use Kestrel by default. In Program.cs, the ConfigureWebHostDefaults method calls UseKestrel:

public static void Main(string[] args)
{
    CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        //use Kestrel 
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
        });

And below are some helpful links about host topic:

Kestrel web server implementation in ASP.NET Core

In-process hosting with IIS and ASP.NET Core

Out-of-process hosting with IIS and ASP.NET Core

Related