InProcess Hosting Model ASP.NET Core
In ASP.NET Core, the “Hosting Model” refers to how the application is hosted and executed.
The Hosting model defines how the application starts, requests are processed, and responses are returned to clients.
In ASP.NET Core, hosting refers to the process of running your web application and making it accessible over the internet or intranet
ASP.NET Core has two types of Hosting Models: InProcess and OutOfProcess.
InProcess Hosting Model in ASP.NET Core:
In this Model the ASP.NET Core Web Application will be hosted inside of the IIS Worker Process, i.e., w3wp.exe, and IIS is the only Web Server going to handle the Incoming HTTP Request.
The application code and the IIS worker process share the same memory space.
This hosting model performs better than OutOfProcess hosting because it eliminates communication overhead between the web server and the application process.
The InProcess Hosting Model works as follows:
1. A request came from the user to IIS on the website’s configured port through the internet over HTTP or HTTPS protocol. Usually 80 (HTTP) or 443 (HTTPS).
2. The ASP.NET Core Module receives the native request and passes it to the IIS HTTP Server (IISHttpServer). IIS HTTP Server is nothing but the In-Process Server implementation for IIS.
3. After the IIS HTTP Server Processes the Request, the request is sent to the ASP.NET Core Application Request Processing (Middleware) Pipeline.
4. The Middleware Pipeline handles the request and passes it on as an HttpContext instance to the application logic. The application logic will get all the requested information from the HttpContext instance and start executing the application logic.
5. Once the Middleware Pipeline handles the request, it will generate the response, which is sent back to IIS through the IIS HTTP Server.
6. Finally, IIS sends the response to the user who initiated the request.
The CreateBuilder() Method in ASP.NET Core?
The CreateBuilder() method sets the Web Host, which will host our application with default preconfigured configurations. The CreateBuilder() method does several things to set the Web host like: -
1. Setting up the Web Server
2. Hosting the web application
3. Loading the Host and Application Configuration from various configuration sources
4. Configuring logging and many more services
5. 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.