liveBook · Manning

Kestrel

As explained in ASP.NET Core in Action, 3e

Kestrel is the cross-platform web server included with ASP.NET Core for receiving and sending HTTP traffic.

Kestrel is the default cross-platform web server for ASP.NET Core. It receives HTTP requests from the network, turns them into an HttpContext that the application can use, and sends the application’s response back as HTTP. The application decides what the response contains; Kestrel handles the network-facing work. section 1.4.2 section 3.1

An ASP.NET Core application typically runs Kestrel inside its own process. After Kestrel creates an HttpContext, the request passes through the middleware pipeline toward an endpoint that generates a response. This self-hosting model differs from older ASP.NET hosting, which relied more tightly on IIS. section 2.4.2 section 3.1

A company information page

When a browser requests a company page, Kestrel receives the request and creates its HttpContext. The application can use the request details to generate the page, then return the response through Kestrel to the browser. Kestrel does not choose the page’s content. section 3.1 section 1.4.2

Two deployment choices affect what Kestrel receives:

  • Expose Kestrel directly to the network. This is supported. section 2.4.2
  • Place a reverse proxy, such as IIS or NGINX, in front of it. The proxy receives internet traffic and forwards requests to the application; this is the more common arrangement and can offer security and performance benefits. section 2.4.2 section 27.1

For HTTPS, a reverse proxy can handle TLS before forwarding traffic to the application. Alternatively, Kestrel can load a production certificate from the Kestrel:Certificates:Default configuration section when it starts, without an application code change. A development certificate is suitable for local testing, not production. section 28.5

Figure 27.1 The hosting model for ASP.NET Core gives flexibility. The same application can run exposed directly to the network, behind various reverse proxies without modification, and even inside the IIS process.
CH27_F01_Lock3

Compare direct exposure, reverse-proxy hosting, and hosting inside the IIS process without treating them as different application implementations. section 27.1

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains request conversion into HttpContext and compares deployment arrangements, but does not detail Kestrel’s protocol implementation.
Examples
Uses a company information page and direct-versus-reverse-proxy hosting diagrams to show request flow.
What it assumes
Starts with browser HTTP requests and explains HttpContext and reverse proxies rather than assuming familiarity with ASP.NET Core hosting.
What you can do after
Operate/configure it by choosing direct or reverse-proxy hosting and configuring a production HTTPS certificate when Kestrel handles TLS.
How it connects
Connects Kestrel to HttpContext, middleware, reverse proxies, IIS, and HTTPS certificates.

Also explained in

Compare how 2 books explain Kestrel →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.