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 + + 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