From c3dd63f521fb967e341202942b7cea44901e7194 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 16:09:04 -0800 Subject: [PATCH 1/2] Show Kestrel overview feature list for .NET 8+ and move memory management to dedicated article (#36443) * Initial plan * Create memory management article and update Kestrel overview Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> * Address code review feedback for memory management article Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> * Address code review feedback and fix moniker ranges Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> * Fix moniker range usage to avoid duplicate H2 headers Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> * Fix moniker ranges to eliminate duplicate headers Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> * Replace not-latest-version include with not-latest-version-without-not-supported-content Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> * Revert include file change in memory-management.md Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> * Remove not-latest-version include from memory-management.md Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com> --- aspnetcore/fundamentals/servers/kestrel.md | 13 +--- .../servers/kestrel/includes/kestrel6.md | 70 ++++++++++++++++--- .../servers/kestrel/memory-management.md | 41 +++++++++++ aspnetcore/toc.yml | 3 + 4 files changed, 108 insertions(+), 19 deletions(-) create mode 100644 aspnetcore/fundamentals/servers/kestrel/memory-management.md diff --git a/aspnetcore/fundamentals/servers/kestrel.md b/aspnetcore/fundamentals/servers/kestrel.md index d4c1ef0dca1d..040a730cf0b2 100644 --- a/aspnetcore/fundamentals/servers/kestrel.md +++ b/aspnetcore/fundamentals/servers/kestrel.md @@ -5,12 +5,12 @@ description: Learn about Kestrel, the cross-platform web server for ASP.NET Core monikerRange: '>= aspnetcore-3.1' ms.author: tdykstra ms.custom: mvc -ms.date: 08/25/2025 +ms.date: 12/04/2025 uid: fundamentals/servers/kestrel --- # Kestrel web server in ASP.NET Core -[!INCLUDE[](~/includes/not-latest-version.md)] +[!INCLUDE[](~/includes/not-latest-version-without-not-supported-content.md)] By [Tom Dykstra](https://github.com/tdykstra), [Chris Ross](https://github.com/Tratcher), and [Stephen Halter](https://twitter.com/halter73) @@ -33,7 +33,7 @@ Kestrel's features include: * Building a reverse proxy with [YARP](https://github.com/microsoft/reverse-proxy). * **Extensibility:** Customize Kestrel through configuration, middleware, and custom transports. * **Performance diagnostics:** Kestrel provides built-in performance diagnostics features, such as logging and metrics. -* **Memory management:** Kestrel includes features for efficient memory management, such as automatic eviction from memory pool. +* **Memory management:** Kestrel includes features for efficient memory management. For more information, see . ## Get started @@ -43,13 +43,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS. For more information on configuring `WebApplication` and `WebApplicationBuilder`, see . -## Optional client certificates - -For information on apps that must protect a subset of the app with a certificate, see [Optional client certificates](xref:security/authentication/certauth#optional-client-certificates). - - -[!INCLUDE[](includes/memory-eviction2.md)] - ## Additional resources diff --git a/aspnetcore/fundamentals/servers/kestrel/includes/kestrel6.md b/aspnetcore/fundamentals/servers/kestrel/includes/kestrel6.md index 3c43dd078ffc..733f32e39b29 100644 --- a/aspnetcore/fundamentals/servers/kestrel/includes/kestrel6.md +++ b/aspnetcore/fundamentals/servers/kestrel/includes/kestrel6.md @@ -1,4 +1,64 @@ -:::moniker range=">= aspnetcore-6.0 <=aspnetcore-9.0" +:::moniker range=">= aspnetcore-8.0 <= aspnetcore-9.0" + +Kestrel is a cross-platform [web server for ASP.NET Core](xref:fundamentals/servers/index). Kestrel is the recommended server for ASP.NET Core, and it's configured by default in ASP.NET Core project templates. + +Kestrel's features include: + +* **Cross-platform:** Kestrel is a cross-platform web server that runs on Windows, Linux, and macOS. +* **High performance:** Kestrel is optimized to handle a large number of concurrent connections efficiently. +* **Lightweight:** Optimized for running in resource-constrained environments, such as containers and edge devices. +* **Security hardened:** Kestrel supports HTTPS and is hardened against web server vulnerabilities. +* **Wide protocol support:** Kestrel supports common web protocols, including: + * HTTP/1.1, [HTTP/2](xref:fundamentals/servers/kestrel/http2) and [HTTP/3](xref:fundamentals/servers/kestrel/http3) + * [WebSockets](xref:fundamentals/websockets) +* **Integration with ASP.NET Core:** Seamless integration with other ASP.NET Core components, such as the middleware pipeline, dependency injection, and configuration system. +* **Flexible workloads**: Kestrel supports many workloads: + * ASP.NET app frameworks such as Minimal APIs, MVC, Razor pages, SignalR, Blazor, and gRPC. + * Building a reverse proxy with [YARP](https://github.com/microsoft/reverse-proxy). +* **Extensibility:** Customize Kestrel through configuration, middleware, and custom transports. +* **Performance diagnostics:** Kestrel provides built-in performance diagnostics features, such as logging and metrics. + +## Get started + +ASP.NET Core project templates use Kestrel by default when not hosted with IIS. In the following template-generated `Program.cs`, the method calls internally: + +:::code language="csharp" source="~/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Program.cs" id="snippet_CreateBuilder" highlight="1"::: + +For more information on configuring `WebApplication` and `WebApplicationBuilder`, see . + +## Behavior with debugger attached + +The following timeouts and rate limits aren't enforced when a debugger is attached to a Kestrel process: + +* +* +* +* +* +* +* + +## Additional resources + + +* + +* + +* + +* + +* +* +* +* +* [RFC 9110: HTTP Semantics (Section 7.2: Host and :authority)](https://www.rfc-editor.org/rfc/rfc9110#field.host) +* When using UNIX sockets on Linux, the socket isn't automatically deleted on app shutdown. For more information, see [this GitHub issue](https://github.com/dotnet/aspnetcore/issues/14134). + +:::moniker-end + +:::moniker range=">= aspnetcore-6.0 < aspnetcore-8.0" Kestrel is a cross-platform [web server for ASP.NET Core](xref:fundamentals/servers/index). Kestrel is the web server that's included and enabled by default in ASP.NET Core project templates. @@ -21,10 +81,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS. For more information on configuring `WebApplication` and `WebApplicationBuilder`, see . -## Optional client certificates - -For information on apps that must protect a subset of the app with a certificate, see [Optional client certificates](xref:security/authentication/certauth#optional-client-certificates). - ## Behavior with debugger attached The following timeouts and rate limits aren't enforced when a debugger is attached to a Kestrel process: @@ -82,10 +138,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS. For more information on building the host, see the *Set up a host* and *Default builder settings* sections of . -## Optional client certificates - -For information on apps that must protect a subset of the app with a certificate, see [Optional client certificates](xref:security/authentication/certauth#optional-client-certificates). - ## Additional resources diff --git a/aspnetcore/fundamentals/servers/kestrel/memory-management.md b/aspnetcore/fundamentals/servers/kestrel/memory-management.md new file mode 100644 index 000000000000..2f8a788fd371 --- /dev/null +++ b/aspnetcore/fundamentals/servers/kestrel/memory-management.md @@ -0,0 +1,41 @@ +--- +title: Memory management in Kestrel +author: tdykstra +description: Learn about memory management in Kestrel, including automatic eviction from memory pools and using memory pool metrics. +monikerRange: '>= aspnetcore-10.0' +ms.author: tdykstra +ms.date: 12/04/2025 +uid: fundamentals/servers/kestrel/memory-management +--- + +# Memory management in Kestrel + +By [Tom Dykstra](https://github.com/tdykstra) + +This article provides guidance for managing memory in Kestrel, including automatic eviction from memory pools and using memory pool metrics. + +## Automatic eviction from memory pool + +The memory pools used by Kestrel, IIS, and HTTP.sys automatically evict memory blocks when the application is idle or under low load. The feature runs automatically and doesn't need to be enabled or configured manually. + +This automatic eviction feature reduces overall memory usage and helps applications stay responsive under varying workloads. In versions of .NET earlier than 10, memory allocated by the pool remained reserved even when not in use. + +### Use memory pool metrics + +The default memory pool used by the ASP.NET Core server implementations includes metrics, which can be used to monitor and analyze memory usage patterns. The metrics are under the name `"Microsoft.AspNetCore.MemoryPool"`. + +For information about metrics and how to use them, see . + +## Manage memory pools + +Besides using memory pools efficiently by evicting unneeded memory blocks, ASP.NET Core provides a built-in [IMemoryPoolFactory](https://source.dot.net/#Microsoft.AspNetCore.Connections.Abstractions/IMemoryPoolFactory.cs) interface and its default implementation, which are available through dependency injection. + +The following code example shows a simple background service that uses the built-in memory pool factory implementation to create memory pools. These pools benefit from the automatic eviction feature: + +:::code language="csharp" source="~/fundamentals/servers/snippets/10.x/my-background-service.cs"::: + +To use a custom memory pool factory, make a class that implements `IMemoryPoolFactory` and register it with dependency injection, as the following example does. Memory pools created this way also benefit from the automatic eviction feature: + +:::code language="csharp" source="~/fundamentals/servers/snippets/10.x/memory-pool-factory.cs"::: + +When you're using a memory pool, be aware of the pool's . diff --git a/aspnetcore/toc.yml b/aspnetcore/toc.yml index ac38460d2ddb..f782f76bddf5 100644 --- a/aspnetcore/toc.yml +++ b/aspnetcore/toc.yml @@ -1190,6 +1190,9 @@ items: - name: Diagnostics displayName: diagnostics uid: fundamentals/servers/kestrel/diagnostics + - name: Memory management + displayName: memory, pool, kestrel + uid: fundamentals/servers/kestrel/memory-management - name: HTTP/2 displayName: deploy, publish, server, Kestrel uid: fundamentals/servers/kestrel/http2 From 10cd9764f058a99c7511204e8d5b28027f2c98fa Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Tue, 9 Dec 2025 09:09:14 -0500 Subject: [PATCH 2/2] Improvements to JS-SPA frameworks article (#36461) --- .../blazor/components/js-spa-frameworks.md | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/aspnetcore/blazor/components/js-spa-frameworks.md b/aspnetcore/blazor/components/js-spa-frameworks.md index 0d4542cc5017..46ab96bb24e3 100644 --- a/aspnetcore/blazor/components/js-spa-frameworks.md +++ b/aspnetcore/blazor/components/js-spa-frameworks.md @@ -20,16 +20,27 @@ This article covers how to render Razor components from JavaScript, use Blazor c + The PU work is tracked by https://github.com/dotnet/aspnetcore/issues/53920. --> ## Angular sample apps - +The following sample apps demonstrate rendering a Razor component as a [Blazor custom element](#blazor-custom-elements) in an Angular app: -* [CustomElementsBlazorSample (Blazor Server) (`javiercn/CustomElementsBlazorSample`, branch: `blazor-server`)](https://github.com/javiercn/CustomElementsBlazorSample/tree/blazor-server): Blazor Server is supported in .NET 8/9. To migrate this .NET 7 sample, see and . -* [CustomElementsBlazorSample (Blazor WebAssembly) (`javiercn/CustomElementsBlazorSample`, branch: `blazor-wasm`)](https://github.com/javiercn/CustomElementsBlazorSample/tree/blazor-wasm): To migrate this .NET 7 sample, see and . +* [CustomElementsBlazorSample (Blazor Server) (`javiercn/CustomElementsBlazorSample` GitHub repository, branch: `blazor-server`)](https://github.com/javiercn/CustomElementsBlazorSample/tree/blazor-server) +* [CustomElementsBlazorSample (Blazor WebAssembly) (`javiercn/CustomElementsBlazorSample` GitHub repository, branch: `blazor-wasm`)](https://github.com/javiercn/CustomElementsBlazorSample/tree/blazor-wasm) + +To migrate either of these .NET 7 samples, see the following resources: + +* +* +* + +The principal updates to make are: + +* Update the [target framework monikers (TFMs)](/dotnet/standard/frameworks) to the latest version. +* Update the .NET package references and Angular dependencies to their latest versions. + + [!INCLUDE[](~/includes/package-reference.md)] ## Render Razor components from JavaScript @@ -340,24 +351,22 @@ builder.Services.AddServerSideBlazor(options => ### Blazor WebAssembly registration -Take the following steps to register a root component as a custom element in a Blazor WebAssembly app. - -Add the namespace to the top of the `Program` file: - -```csharp -using Microsoft.AspNetCore.Components.Web; -``` +Register a root component as a custom element in a Blazor WebAssembly app. In the following example, the code: -Add a namespace for the app's components. In the following example, the app's namespace is `BlazorSample` and the components are located in the `Pages` folder: +* Adds a namespace for the app's components. In the example, the app's namespace is `BlazorSample`, and the components are located in the `Pages` folder. +* Provides access to the API in the namespace. +* Calls on to register the `Counter` component with the custom HTML element `my-counter`. ```csharp using BlazorSample.Pages; -``` +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -Call on . The following example registers the `Counter` component with the custom HTML element `my-counter`: +var builder = WebAssemblyHostBuilder.CreateDefault(args); -```csharp builder.RootComponents.RegisterCustomElement("my-counter"); + +await builder.Build().RunAsync(); ``` ### Use the registered custom element @@ -475,3 +484,7 @@ Generate JavaScript (JS) components from Razor components for JavaScript technol > [!WARNING] > The Angular and React component features are currently **experimental, unsupported, and subject to change or be removed at any time**. We welcome your feedback on how well this particular approach meets your requirements. + +## Additional resources + +