Wednesday, 31 March 2021

Understanding OutOfProcess Hosting Model in ASP.NET Core

In this article, we will learn OutOfProcess Hosting Model in ASP.NET Core. If you are new to ASP.NET Core, then I will recommend you to go through the below articles of this series:

In the previous article, we learned, How to configure InProcess hosting model in ASP.NET Core. We configured the AspNetCoreHostingModel value as InProcess in the .csproj file and saw that the application is hosted through IISExpress / wpw3.exe worker process.
In this article, we will see how to host an application on the OutOfProcess hosting model. In OutOfProcess hosting model, there are two web servers, one is Internal Web Server which is basically a Kestrel server and another is External Web Server which can be either IIS, Ngnix, Apache, etc. dotnet.exe is the process that runs and hosts the application with the Kestrel Web Server.

1. Internal Web Server: In an internal web server, the Kestrel web server is the internet-facing web server as all the HTTP requests are directly processed by it.
2. External Web Server: In External Web Server, Reverse proxy server which can be either IIS, Ngnix, Apache, etc. is used along with Kestrel web Server. A reverse Proxy server provides additional security as well as configurations that are not available in Kestrel Server. It also provides load balancing functionality.

Let’s edit the .csproj file and set AspNetCoreHostingModel value as OutOfProcess (Value of AspNetCoreHostingModel is case-insensitive)

Or we can also change its value by right-clicking on the project and click on the properties as shown in the below image.
Click on debug menu, and change the value of the Hosting Model from the dropdown to OutOfProcess. We can use any one method in order to change the Hosting Model.
Now let’s run the application through IIS Express. You can see that the application is served through Kestrel Server (with DotNet.exe process)


Now let’s run the Application through Launch Application by selecting the profile to run the application with DotNet CLI or by the DotNet CLI command in order to check the Worker Process / Server serving the application. As we can see Kestrel server is serving the application.


Some of the difference between the InProcess vs OutOfProcess hosting model are:
1. In InProcess hosting model, request and response are served through w3wp.exe or IISExpress whereas in the OutOfProcess worker process involved is dotnet.exe
2. In InProcess hosting model, single web server is used whereas, In OutOfProcess hosting model, two web servers can be used.
3. InProcess hosting model provides better performance as compared to OutOfProcess hosting model. 

I hope this article helped you in understanding the OutOfProcess hosting model.
Thanks.

0 comments:

Post a comment

Subscribe Now

Popular Posts

Contact us

Name

Email *

Message *

Subscribe us on YouTube

Like us on Facebook