Skip to content

Commit 8d17c35

Browse files
CopilotJamesNKguardrex
authored
Add QuicTransportOptions configuration documentation to HTTP/3 guide (#36341)
Co-authored-by: JamesNK <303201+JamesNK@users.noreply.github.com> Co-authored-by: guardrex <1622880+guardrex@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: James Newton-King <james@newtonking.com>
1 parent ca5329b commit 8d17c35

File tree

2 files changed

+45
-1
lines changed
  • aspnetcore/fundamentals/servers/kestrel

2 files changed

+45
-1
lines changed

aspnetcore/fundamentals/servers/kestrel/http3.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
title: Use HTTP/3 with the ASP.NET Core Kestrel web server
3+
ai-usage: ai-assisted
34
author: wtgodbe
45
description: Learn about using HTTP/3 with Kestrel, the cross-platform web server for ASP.NET Core.
56
monikerRange: '>= aspnetcore-6.0'
67
ms.author: wigodbe
78
ms.custom: mvc, linux-related-content
8-
ms.date: 06/08/2025
9+
ms.date: 11/13/2025
910
uid: fundamentals/servers/kestrel/http3
1011
---
1112

@@ -64,6 +65,25 @@ Because not all routers, firewalls, and proxies properly support HTTP/3, HTTP/3
6465

6566
For more information, see <xref:fundamentals/servers/kestrel/endpoints>.
6667

68+
## Configure QuicTransportOptions
69+
70+
QUIC transport options can be configured by calling the <xref:Microsoft.AspNetCore.Hosting.WebHostBuilderQuicExtensions.UseQuic%2A> extension method on <xref:Microsoft.AspNetCore.Hosting.IWebHostBuilder>.
71+
72+
:::code language="csharp" source="samples/6.x/KestrelSample/Snippets/Program.cs" id="snippet_UseQuicWithOptions" highlight="3-8":::
73+
74+
The following table describes the available <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions>.
75+
76+
| Option | Default | Description |
77+
| ------ | ------- | ----------- |
78+
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxBidirectionalStreamCount> | `100` | The maximum number of concurrent bidirectional streams per connection. |
79+
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxUnidirectionalStreamCount> | `10` | The maximum number of concurrent inbound unidirectional streams per connection. |
80+
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxReadBufferSize> | `1024 * 1024` (1 MB) | The maximum read buffer size in bytes. |
81+
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxWriteBufferSize> | `64 * 1024` (64 KB) | The maximum write buffer size in bytes. |
82+
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.Backlog> | `512` | The maximum length of the pending connection queue. |
83+
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.DefaultStreamErrorCode> | `0x010c` (H3_REQUEST_CANCELLED) | Error code used when the stream should abort the read or write side of the stream internally. |
84+
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.DefaultCloseErrorCode> | `0x100` (H3_NO_ERROR) | Error code used when an open connection is disposed. |
85+
86+
6787
## Alt-svc
6888

6989
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.

aspnetcore/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Snippets/Program.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.AspNetCore.Server.Kestrel.Core;
1010
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
1111
using Microsoft.AspNetCore.Server.Kestrel.Https;
12+
using Microsoft.AspNetCore.Server.Kestrel.Transport.Quic;
1213

1314
namespace KestrelSample.Snippets;
1415

@@ -595,4 +596,27 @@ public static void Http3(string[] args)
595596
});
596597
// </snippet_Http3>
597598
}
599+
600+
public static void UseQuicWithOptions(string[] args)
601+
{
602+
// <snippet_UseQuicWithOptions>
603+
var builder = WebApplication.CreateBuilder(args);
604+
605+
builder.WebHost.UseQuic(options =>
606+
{
607+
#pragma warning disable CA2252 // Using preview features
608+
options.MaxBidirectionalStreamCount = 200;
609+
#pragma warning restore CA2252
610+
});
611+
612+
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
613+
{
614+
serverOptions.ListenAnyIP(5001, listenOptions =>
615+
{
616+
listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
617+
listenOptions.UseHttps();
618+
});
619+
});
620+
// </snippet_UseQuicWithOptions>
621+
}
598622
}

0 commit comments

Comments
 (0)