diff --git a/aspnetcore/fundamentals/servers/kestrel/http3.md b/aspnetcore/fundamentals/servers/kestrel/http3.md index 5832d46e6df0..d46b49624b9b 100644 --- a/aspnetcore/fundamentals/servers/kestrel/http3.md +++ b/aspnetcore/fundamentals/servers/kestrel/http3.md @@ -1,11 +1,12 @@ --- title: Use HTTP/3 with the ASP.NET Core Kestrel web server +ai-usage: ai-assisted author: wtgodbe description: Learn about using HTTP/3 with Kestrel, the cross-platform web server for ASP.NET Core. monikerRange: '>= aspnetcore-6.0' ms.author: wigodbe ms.custom: mvc, linux-related-content -ms.date: 06/08/2025 +ms.date: 11/13/2025 uid: fundamentals/servers/kestrel/http3 --- @@ -64,6 +65,25 @@ Because not all routers, firewalls, and proxies properly support HTTP/3, HTTP/3 For more information, see . +## Configure QuicTransportOptions + +QUIC transport options can be configured by calling the extension method on . + +:::code language="csharp" source="samples/6.x/KestrelSample/Snippets/Program.cs" id="snippet_UseQuicWithOptions" highlight="3-8"::: + +The following table describes the available . + +| Option | Default | Description | +| ------ | ------- | ----------- | +| | `100` | The maximum number of concurrent bidirectional streams per connection. | +| | `10` | The maximum number of concurrent inbound unidirectional streams per connection. | +| | `1024 * 1024` (1 MB) | The maximum read buffer size in bytes. | +| | `64 * 1024` (64 KB) | The maximum write buffer size in bytes. | +| | `512` | The maximum length of the pending connection queue. | +| | `0x010c` (H3_REQUEST_CANCELLED) | Error code used when the stream should abort the read or write side of the stream internally. | +| | `0x100` (H3_NO_ERROR) | Error code used when an open connection is disposed. | + + ## Alt-svc HTTP/3 is discovered as an upgrade from HTTP/1.1 or HTTP/2 via the [`alt-svc`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Alt-Svc) header. That means the first request will normally use HTTP/1.1 or HTTP/2 before switching to HTTP/3. Kestrel automatically adds the `alt-svc` header if HTTP/3 is enabled. diff --git a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs index 331b5723b84f..511857c41bae 100644 --- a/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs +++ b/aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core.Features; using Microsoft.AspNetCore.Server.Kestrel.Https; +using Microsoft.AspNetCore.Server.Kestrel.Transport.Quic; namespace KestrelSample.Snippets; @@ -595,4 +596,27 @@ public static void Http3(string[] args) }); // } + + public static void UseQuicWithOptions(string[] args) + { + // + var builder = WebApplication.CreateBuilder(args); + + builder.WebHost.UseQuic(options => + { +#pragma warning disable CA2252 // Using preview features + options.MaxBidirectionalStreamCount = 200; +#pragma warning restore CA2252 + }); + + builder.WebHost.ConfigureKestrel((context, serverOptions) => + { + serverOptions.ListenAnyIP(5001, listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; + listenOptions.UseHttps(); + }); + }); + // + } }