Core InProcess Hosting


ASP.NET Core InProcess Hosting

ASP.NET Core InProcess Hosting Model

In this article, I am going to discuss the ASP.NET Core InProcess Hosting Model in detail. Please read our previous article before proceeding to this article where we discussed the ASP.NET Core Main method . As part of this article, we are going to discuss the following pointers in detail.

  1. What are the Tasks performed by CreateDefaultBuilder() method?
  2. What is InProcess hosting in ASP.NET Core?
  3. How to Configure InProcess hosting in ASP.NET Core?
  4. How to host ASP.NET Core Application using InProcess hosting Model?
  5. What happens when we set the Hosting model as InProcess?
  6. How does the InProcess hosting work in ASP.NET Core?
  7. What is IIS Express?
  8. Why InProcess Hosting Gives Better Performance that the OutOfProcess Hosting Model?

We are going to work with the same application that we created in our previous article. As we already discussed when we create an ASP.NET Core web application, then the ASP.NET Core framework creates the following Program class with the Main method for us.

ASP.NET Core InProcess Hosting Model

When we execute an ASP.NET core application then the .NET Core runtime looks for the Main() method. The Main() method is the entry point for the .net core application to execute.

As you can see from the above image the Main() method of the Program class calls the static CreateHostBuilder() method. Then the CreateHostBuilder() method calls the static CreateDefaultBuilder()method on the Host class. The CreateDefaultBuilder() method sets the web host which will host our application with default preconfigured configurations.

What are the Tasks performed by CreateDefaultBuilder() method?

As part of setting the web host, the CreateDefaultBuilder() method does several things. Some of them are as follows

  1. Setting up the webserver (will discuss in this article)
  2. Loading the host and application configuration from various configuration sources (will discuss in our upcoming articles)
  3. Configuring logging (will discuss in our upcoming articles)

Let us discuss what exactly the CreateDefaultBuilder() method does to configure and set up the webserver. 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.

Here in this article, we are going to discuss the InProcess hosting model and in a later article, we will discuss the OutOfProcess hosting model.

Note: When we create a new ASP.NET Core Web application by using any template, by default the project file is created with InProcess hosting which is used for hosting the application in IIS or IIS Express scenarios.

How to verify this?

In order to verify the same, open the project properties. Right-click on your project and select the properties option from the context menu. Once you open the properties window, then select the Debug and have a look at the value of the Hosting Model drop-down list as shown in the below image. The drop-down list contains three values i.e. Default (InProcess), InProcess, and Out Of Process. In our upcoming articles, we will discuss the Out Of Process hosting model.


Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *