Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

Definition of Host in ASP.NET

Tags: glossary, asp.net, asp.net-core

Note: This might be out of date by now, and most likely is, given the rapidity with which ASP.NET Core is changing, for the better.

Definitions

What is a host in the ASP.NET world? From reading some ASP.NET articles, these are the ways the team uses the word.

host (verb)

  1. to start, manage, and stop another process: "host one of several .NET CLRs"

  2. to mediate between an HTTP server and an application: "hosting the application on the server"

Here is an example that uses both sense (1) and (2) in the same paragraph:

The ASP.NET hosting layer... is responsible for finding the Web server to run on [2], finding the startup logic for the application 1, hosting the application on the server [2] and then cleaning up when the application is shut down 1. It also provides a number of additional hosting-related services to applications.

That is the verb form. Here it is as a noun.

host (noun)

  1. a process that starts, manages, and stops another process: "find and call the native CLR host"; "The native CLR host has three main responsibilities"; "When the entry point of the native host returns"; "in most scenarios, you’d use an application host to help resolve application dependencies and run your app"; "a flexible, cross-platform runtime host"

  2. a process that mediates between the server and the application. "Web servers use feature interfaces to expose low-level functionality to the host layer. The hosting layer wraps these feature interfaces in a strongly typed HttpContext that’s then passed through to the application."

  3. a network connected physical (or virtual) machine. [This is a classical definition of the word host. The ASP.NET team does not often use this sense of the word.]

Specific ASP.NET Related Hosts

In an early 2015 article about the new ASP.NET 5 (now ASP.NET Core), the term host is used to refer to three specific hosts.

  • Runtime Host. Also known as the CLR Host, this is a process (the host process) that starts, manages, and stops the .NET Common Language Runtime. During startup it calls the entry point (e.g. main) of either the application or the application host.

  • Application Host. This is an optional process that starts, manages, and stops a .NET application. A .NET application does not need an application host; we can start our application directly, if we do not need the application host's services, which include project.json and NuGet support.

  • ASP.NET Hosting Layer. This layer starts an ASP.NET Web Application. It finds Startup.cs and runs its Configure method.

Discussion

In ASP.NET Core, a native process starts the runtime host and the runtime host starts the common language runtime (CLR.) The CLR starts the application host, which starts the .NET application. The .NET application starts the ASP.NET hosting layer, which finally starts on Web Application. That is application startup. An HTTP requests comes into our network host, which passes it on to the server (via the reverse proxy), which passes it to the ASP.NET hosting layer. The hosting layer turns it into an HttpContext object that the middleware and web app can consume. That is receiving the request.

Schematic

HTTP Request
           ↓
Network Host (physical / virtual machine)
           ↓
Operating System (Windows / Linux)
           ↓
Reverse Proxy (IIS / NGINX)
           ↓
HTTP Server (Kestrel / Nowin)
 ↑         ↓
ASP.NET Hosting Layer → Middleware & Web App 
 ↑  
.NET Application
 ↑
.NET Application Host (optional)
 ↑
CoreCLR
 ↑ 
Runtime Host
 ↑ 
Native Process (klr.exe, dnx.exe, dotnet.exe...)
 ↑
Application Startup

References

  • https://msdn.microsoft.com/en-us/magazine/dn913182.aspx

  • http://docs.asp.net/en/latest/conceptual-overview/aspnet.html

  • https://en.wikipedia.org/wiki/Webhostingservice

  • https://en.wikipedia.org/wiki/Internethostingservice