Hello
Hello

Reputation: 816

I don't use Kestrel as the web server and enable IIS integration in the code but Response Header showing the server is Kestrel

I use .net core 2.1 and published it to IIS 8.5. I have a hard time to understand the concept OF .NET core hosting.

The program.cs is

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
   }

You see there is no UseKestrel word, but in the response header, it shows Server is Kestrel.

kestrel

Also in the project file, there is no <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>. And I don't have the code such as UseIISIntegration.

Summary of my questions:

  1. Why it uses Kestrel?
  2. Is it inprocess or outofprocess?
  3. Which file handles this particular case? I assume that it is AspNetCoreModule, but which file?(w3wp?)

Upvotes: 2

Views: 3136

Answers (2)

ppiwow
ppiwow

Reputation: 21

If you compare documentation:

v 2.1: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.1

and v 2.2: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.2

you can see at the very beginning the differences between the versions.

In 2.1:

Because ASP.NET Core apps run in a process separate from the IIS worker process, the module also handles process management. The module starts the process for the ASP.NET Core app when the first request arrives and restarts the app if it crashes. This is essentially the same behavior as seen with ASP.NET 4.x apps that run in-process in IIS that are managed by the Windows Process Activation Service (WAS).

And in v 2.2:

The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline to either: Host an ASP.NET Core app inside of the IIS worker process (w3wp.exe), called the in-process hosting model. Forward web requests to a backend ASP.NET Core app running the Kestrel server, called the out-of-process hosting model.

In-process is default for v 2.2.

I tested my setup on v 3.1, in-process model and it works as you expected. Locally, it returns kestrel, on IIS, it returns IIS server.

All your answers are under those two links.

Upvotes: 2

Vy Do
Vy Do

Reputation: 52636

Your question:

  1. Why it uses Kestrel?
  2. Is it inprocess or outofprocess?
  3. Which file handles this particular case? I assume that it is AspNetCoreModule, but which file?(w3wp?)

Answer:

  1. Because you use dotnet run command for running.
  2. outprocess
  3. w3wp.exe and dotnet.exe
  • Your hosting model is:

enter image description here

  • Your hosting model is not:

enter image description here

Image source and reference document: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1#out-of-process-hosting-model

Upvotes: 3

Related Questions