In this article, we will learn about In-Process and Out-Of-Process hosting models in ASP.NET Core.
At the point when we push your web application to IIS, different processes to the application are taken care of by what is known as the ASP.NET Core Module.
Let’s understand In-Process and Out-Of-Process Hosting Model
Understanding and picking the right hosting model is one of the crucial phases of software deployment on production. In this section of the article, we will understand which hosting process model is good for deployment. Let’s look into the InProcess Hosting and OutOfProcess Hosting model in detail.
What is the In-Process Hosting Model?
In-process models pass the default Kestrel web server of ASP.NET Core. When the web request hits the IIS server, the IIS HTTP server converts the request and sends it to ASP.NET Core middleware. The .NET Core middleware passes the request as an HttpContext
to execute the code.
Under default settings, the hosting model for your application is in process. This implies ASP.NET Core Module sends the requests to the IIS HTTP Server.
This outcome is incredible execution when contrasted with the Out Of Process model.
What is the Out-Of-Process Hosting Model?
Before ASP.NET Core 2.2, the only hosting model option available is OutOfProcessModel. Out-of-Process model uses an IIS server as a reverse proxy server.
If you want to implement the hosting model as an out-of-process model in your ASP.NET Core Application then IIS HTTP Server will not be utilized.
In the Out-Of-Process Hosting, the Kestrel web server is utilized to handle your requests. The out-of-process model can be used with .Net Core V2.2 and earlier. This hosting model uses IIS as a proxy to forward the incoming requests to dotnet.exe.
How to change from Out-Of-Process to In-Process?
If you host a large and complex .NET Core application and you are concerned about the performance of the application then you should switch to the In-Process hosting model in case you are using the outofprocess hosting model. We can switch from the Out-of-process hosting model to the In-process hosting model easily. Open .csproj
file or right-click on the project file and select Edit Project.
Change this line ->
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
To below line –
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
What is Kestrel?
The Kestrel is an open-source and cross-platform web server for the ASP.NET Core application. That implies this server supports Windows, Linux, and macOS.
ASP.NET Core Module sends the requests to the Kestrel web server in contrast with the In-process hosting model and Out-Of-Process model in slower execution.
ASP.NET Core applications run without the Kestrel web server too. Naturally, the In-Process facilitating model will work out of the Kestrel web server and it will utilize an IIS web server like w3wp.exe or iisexpress.exe
Final Words
So, this article explains about In-Process and Out-Of-Process hosting models in ASP.NET Core. The in-process hosting model is better than the Out-of-process hosting model. The in-process hosting model is available for .Net core V2.2 and later. A newer version of the ASP.Net Core application automatically configures InProcess hosting, in case you are migrating from an older version of the ASP.NET Core application then you have to do a project-level configuration.