ASP.NET Core Interview Question #211

What is Kestrel and what role does it play in production hosting?

Testing, Deployment & Hosting Senior Advanced

Quick Interview Answer

Kestrel is the cross-platform web server used by ASP.NET Core. It accepts HTTP connections and hosts the application's ASP.NET Core request pipeline.

Detailed Explanation

Kestrel is the cross-platform web server used by ASP.NET Core. It accepts HTTP connections and hosts the application's ASP.NET Core request pipeline.

Kestrel can be internet-facing in supported configurations, but many production architectures place a reverse proxy or managed ingress in front of it for concerns such as TLS termination, public routing, load balancing, centralized limits, or platform integration.

The hosting design should follow the requirements and security model of the deployment platform rather than assuming one topology fits every application.

Code Example

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(options =>
{
    // Custom limits/endpoints can be configured here
    // when required by the hosting architecture.
});

var app = builder.Build();