Kestrel is the cross-platform web server included with ASP.NET Core. It is designed for high performance and lightweight hosting of web applications. Kestrel can be used as a standalone server or behind a reverse proxy like IIS, Nginx, or Apache.
Key Features:
- High-performance, asynchronous web server
- Cross-platform: Windows, Linux, macOS
- Can run standalone or behind a reverse proxy
- Supports HTTPS and HTTP/2
- Lightweight and highly configurable
Example:
Configure Kestrel in Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(options =>
{
options.ListenAnyIP(5000); // HTTP
options.ListenAnyIP(5001, listenOptions => listenOptions.UseHttps("cert.pfx", "password")); // HTTPS
});
var app = builder.Build();
app.MapGet("/", () => "Hello Kestrel!");
app.Run();
Kestrel in ASP.NET Core provides fast, reliable, and flexible web hosting, making it ideal for modern cloud-based and on-premises applications.
Citations: