Part - 4 ASP - NET Core InProcess Hosting
Part - 4 ASP - NET Core InProcess Hosting
Part - 4 ASP - NET Core InProcess Hosting
Note: There are trade-offs between each of the hosting models. By default, the in-process hosting
model is used due to better performance and diagnostics.
Once you click on the Create a new project box, it will open the “Create a new project” window. This
window includes different .NET 6 application templates. Here we will create a simple Web application
from scratch, so select the ASP.NET Core Empty Project template and then click on the Next button
as shown in the below image.
Once you click on the Next button, it will open the following Configure Your New Project window.
Here, you need to provide the necessary information to create a new project. First, give an appropriate
name for your project (FirstCoreWebApplication), set the location where you want to create this
project, and the solution name for the ASP.NET Core Web application. And finally, click on
the Next button as shown in the image below.
Once you click on the Create button, it will create a new ASP.NET Core Web Application in Visual Studio
2022 using .NET 6 with the following file and folder structure.
Let us understand what exactly the CreateBuilder() method does to configure and set up the Web
Server. From a hosting point of view, an ASP.NET Core Web application can be hosted in two ways i.e.
InProcess Hosting or OutOfProcess Hosting. Let us first discuss the InProcess Hosting Model and
then, we will discuss the OutOfProcess Hosting Model.
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
</Project>
Once you click on the Open debug launch profiles UI button, then it will open the Launch Profile window.
From this window select IIS Express and scroll down and somewhere you will find the Hosting Model
From the performance point of view, the InProcess Hosting Model delivers significantly higher request
throughput than the OutOfProcess Hosting Model. Why we will discuss this latter part of this session.
The process name that will be used to execute the application is w3wp in the case of IIS. Similarly, if it
is IIS Express then the process name will be iisexpress.
With this change, Visual Studio will set IIS Express as the Launch Profile as shown in the below image.
You are getting the above message from the following MapGet method which is present
inside the Main method of the Program class as shown in the below image.
app.Run();
}
}
}
Now when we run the application from visual studio, it should display the message in the browser as
shown below. This is because by default Visual Studio uses IISExpress when we run an application.
The internal Web Server is called Kestrel and the external web server can
be IIS, Nginx, or Apache. With the InProcess Hosting Model, there is only one web server i.e. IIS. So,
Next=> So, before understanding the Out of Process Hosting Model to host our ASP.NET Core Web
Application, first we need to understand What is Kestrel Web Server and How Kestrel Web Server
works, and then we will discuss the Out of Process Hosting Model.