Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion aspnetcore/fundamentals/servers/kestrel/http3.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ description: Learn about using HTTP/3 with Kestrel, the cross-platform web serve
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
ai-usage: ai-assisted
---

# Use HTTP/3 with the ASP.NET Core Kestrel web server
Expand Down Expand Up @@ -64,6 +65,25 @@ Because not all routers, firewalls, and proxies properly support HTTP/3, HTTP/3

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

## Configure QuicTransportOptions

QUIC transport options can be configured by calling the <xref:Microsoft.AspNetCore.Hosting.WebHostBuilderQuicExtensions.UseQuic%2A> extension method on <xref:Microsoft.AspNetCore.Hosting.IWebHostBuilder>.

:::code language="csharp" source="samples/6.x/KestrelSample/Snippets/Program.cs" id="snippet_UseQuicWithOptions" highlight="3-8":::

The following table describes the available <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions>:

| Option | Default | Description |
|--------|---------|-------------|
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxBidirectionalStreamCount> | `100` | The maximum number of concurrent bi-directional streams per connection. |
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxUnidirectionalStreamCount> | `10` | The maximum number of concurrent inbound uni-directional streams per connection. |
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxReadBufferSize> | `1024 * 1024` (1 MB) | The maximum read buffer size in bytes. |
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.MaxWriteBufferSize> | `64 * 1024` (64 KB) | The maximum write buffer size in bytes. |
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.Backlog> | `512` | The maximum length of the pending connection queue. |
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.DefaultStreamErrorCode> | `0x010c` (`H3_REQUEST_CANCELLED`) | Error code used when the stream needs to abort the read or write side of the stream internally. The value must be between `0x0` and `0x3FFFFFFFFFFFFFFF`. |
| <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportOptions.DefaultCloseErrorCode> | `0x100` (`H3_NO_ERROR`) | Error code used when an open connection is disposed. The value must be between `0x0` and `0x3FFFFFFFFFFFFFFF`. |


## 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -595,4 +596,27 @@ public static void Http3(string[] args)
});
// </snippet_Http3>
}

public static void UseQuicWithOptions(string[] args)
{
// <snippet_UseQuicWithOptions>
var builder = WebApplication.CreateBuilder(args);

#pragma warning disable CA2252 // Using preview features
builder.WebHost.UseQuic(options =>
{
options.MaxBidirectionalStreamCount = 200;
});
#pragma warning restore CA2252

builder.WebHost.ConfigureKestrel((context, serverOptions) =>
{
serverOptions.ListenAnyIP(5001, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
listenOptions.UseHttps();
});
});
// </snippet_UseQuicWithOptions>
}
}