Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions aspnetcore/blazor/components/virtualization.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: guardrex
description: Learn how to use component virtualization in ASP.NET Core Blazor apps.
monikerRange: '>= aspnetcore-5.0'
ms.author: wpickett
ms.date: 08/26/2026
ms.date: 09/10/2026
uid: blazor/components/virtualization
---
# ASP.NET Core Razor component virtualization
Expand Down Expand Up @@ -279,7 +279,7 @@ The <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> com

## Scroll to a specific item

The <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component provides two ways to control scroll position: `InitialItemIndex` for the first render and `ScrollToIndexAsync` for programmatic scrolling after the component is rendered.
The <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component provides two ways to control scroll position: `InitialItemIndex` for the first render and `ScrollToItemAsync` for programmatic scrolling after the component is rendered.

### `InitialItemIndex` parameter

Expand All @@ -293,7 +293,7 @@ Set `InitialItemIndex` to open the list at a specific item index on the first in

### `ScrollToItemAsync` method

Call `ScrollToIndexAsync` to programmatically scroll to an item after the first render. The scroll is instant (no animation). The method returns a <xref:System.Threading.Tasks.Task> that completes when the target item is aligned to the top of the viewport. Cancellation is supported via a <xref:System.Threading.CancellationToken>.
Call `ScrollToItemAsync` to programmatically scroll to an item after the first render. The scroll is instant (no animation). The method returns a <xref:System.Threading.Tasks.Task> that completes when the target item is aligned to the top of the viewport. Cancellation is supported via a <xref:System.Threading.CancellationToken>.

If multiple calls occur, the last call wins—earlier calls complete normally but only the final target is honored. If the user scrolls during a programmatic scroll, the user's scroll takes precedence. Calling before the first interactive render throws an <xref:System.InvalidOperationException>.

Expand All @@ -311,7 +311,7 @@ If multiple calls occur, the last call wins—earlier calls complete normally bu
{
if (virtualizeComponent is not null)
{
await virtualizeComponent.ScrollToIndexAsync(200);
await virtualizeComponent.ScrollToItemAsync(200);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion aspnetcore/release-notes/aspnetcore-11.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ai-usage: ai-assisted
author: wadepickett
description: Learn about the new features in ASP.NET Core in .NET 11.
ms.author: wpickett
ms.date: 09/08/2026
ms.date: 09/10/2026
uid: aspnetcore-11
---
# What's new in ASP.NET Core in .NET 11
Expand Down
67 changes: 39 additions & 28 deletions aspnetcore/release-notes/aspnetcore-11/includes/blazor.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ The `blazor-wasm-servicedefaults` project template creates a service defaults li

[`Microsoft.AspNetCore.Components.Gateway`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.Gateway) is a lightweight ASP.NET Core host that replaces [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer) for serving standalone Blazor WebAssembly apps during development and production.

<!-- UPDATE 11.0 - Update the word "preview" in the following remark at RC
to "release candidate." Remove entirely at GA. -->

To adopt the Gateway in an existing standalone Blazor WebAssembly app, reference the preview `Microsoft.AspNetCore.Components.Gateway` package in the app's project file.
To adopt the Gateway in an existing standalone Blazor WebAssembly app, reference the `Microsoft.AspNetCore.Components.Gateway` package in the app's project file.

[!INCLUDE[](~/includes/package-reference.md)]

Expand Down Expand Up @@ -590,27 +587,50 @@ Hosted services are started when the app starts and stopped when it shuts down,

### Configure Blazor client behavior from the server

<!-- UPDATE 11.0 - We need reference article coverage for this. I'll get to it soon! -->
<!-- UPDATE 11.0 - We need reference article coverage for this, but we'll wait
for the API to completely stabilize at RC2 and possibly
for content from the PU to arrive. -->
Comment thread
guardrex marked this conversation as resolved.
Resolved

Blazor apps can now configure client-side startup behavior from the server in C# when mapping Razor components instead of hand-writing `Blazor.start` JavaScript. `WithBrowserOptions` sets options that the server serializes into the rendered page and the Blazor script applies in the browser, across the Server, WebAssembly, and Auto render modes. The options cover the client log level, interactive Server reconnection, whether enhanced navigation preserves the DOM, and a WebAssembly runtime's environment name, culture, and environment variables:

```csharp
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode()
.WithBrowserOptions(options =>
{
options.LogLevel = LogLevel.Warning;
options.InteractiveServer.ReconnectionDialogId = "reconnect-dialog";
options.InteractiveServer.ReconnectionMaxRetries = 10;
options.InteractiveServer.ReconnectionRetryInterval = TimeSpan.FromSeconds(1.5);
options.InteractiveWebAssembly.EnvironmentVariables["OTEL_EXPORTER_OTLP_ENDPOINT"] =
"https://localhost:4318";
options.StaticServer.CircuitInactivityTimeout = TimeSpan.FromSeconds(1.5);
options.StaticServer.PreserveDom = true;
options.InteractiveWebAssembly.ApplicationCulture = "en-ca";
options.InteractiveWebAssembly.EnvironmentName = "Staging";
options.InteractiveWebAssembly.EnvironmentVariables["OTEL_EXPORTER_OTLP_ENDPOINT"] =
"https://localhost:4318";
options.LogLevel = LogLevel.Warning;
});
```

You can also set the options from a component with `<ConfigureBrowser>` or read the resolved options from `HttpContext` with `GetBrowserOptions()`.
You can also set the options in a Razor component with the `ConfigureBrowser` component:

```razor
<ConfigureBrowser Options="RequestBrowserOptions" />

...

@code {
private BrowserOptions RequestBrowserOptions => new()
{
LogLevel = LogLevel.Trace,
StaticServer = { PreserveDom = true }
};
}
```

Read the resolved options from `HttpContext` with `GetBrowserOptions()`:

```razor
@BrowserOptions.GetBrowserOptions(HttpContext).LogLevel
```

For more information, see the following resources:

Expand Down Expand Up @@ -783,17 +803,7 @@ For more information, see [Fix TempData and SupplyParameterFromSession persisten

### Antiforgery middleware (`app.UseAntiforgery()`) optional in Blazor Web Apps

<!-- HOLD FOR PREVIEW 7 language changes ...

Redundant `app.UseAntiforgery()` removed from Blazor Web App templates

Next paragraph: ... has been removed.

Next paragraph: Remove the last sentence.

-->

[CSRF protection](xref:security/anti-request-forgery#automatic-csrf-protection-in-aspnet-core) is enabled by default via the auto-injected CSRF protection middleware, so the explicit `app.UseAntiforgery()` call in Blazor Web App templates is optional, unless required in specific use cases. In a future preview release, the middleware will be removed from the request processing pipeline for apps created from the Blazor Web App project template.
[CSRF protection](xref:security/anti-request-forgery#automatic-csrf-protection-in-aspnet-core) is enabled by default via the auto-injected CSRF protection middleware, so an explicit `app.UseAntiforgery()` call in a Blazor Web App is usually unnecessary and should only be added for specific use cases. The call no longer appears in apps created from the Blazor Web App project template.

For more information, see the following resources:

Expand All @@ -808,12 +818,10 @@ General coverage for the new automatic CSRF protection in ASP.NET Core:

### Blazor Virtualize can scroll to an item

<!-- UPDATE 11.0 - Cross-link to ref content -->

The `Virtualize<TItem>` component can now open at a specific item and scroll to any item on demand. Two new public APIs make this possible:

* `InitialItemIndex` positions the list at a given item on the first interactive render, so the list opens at that item without a flash of the first item.
* `ScrollToIndexAsync(int itemIndex, CancellationToken cancellationToken = default)` scrolls to an item at any time after the first render and returns a `Task` that completes when the target is aligned to the top of the viewport.
* `ScrollToItemAsync(int itemIndex, CancellationToken cancellationToken = default)` scrolls to an item at any time after the first render and returns a `Task` that completes when the target is aligned to the top of the viewport.

```razor
<Virtualize TItem="Product" Items="products" InitialItemIndex="500" @ref="list">
Expand All @@ -826,13 +834,16 @@ The `Virtualize<TItem>` component can now open at a specific item and scroll to
private Virtualize<Product> list = default!;
private List<Product> products = ProductCatalog.All;

private async Task GoToTop() => await list.ScrollToIndexAsync(0);
private async Task GoToTop() => await list.ScrollToItemAsync(0);
}
```

Out-of-range indexes are clamped to the valid range. If a second `ScrollToIndexAsync` call starts while one is still in flight, the last call wins. Calling `ScrollToIndexAsync` before the first interactive render throws `InvalidOperationException`; use `InitialItemIndex` to set the starting position instead.
Out-of-range indexes are clamped to the valid range. If a second `ScrollToItemAsync` call starts while one is still in flight, the last call wins. Calling `ScrollToItemAsync` before the first interactive render throws `InvalidOperationException`; use `InitialItemIndex` to set the starting position instead.

For more information, see the following resources:

For more information, see [Add `InitialIndex` (sic) parameter and `ScrollToIndexAsync` API to `Virtualize<TItem>` (`dotnet/aspnetcore` #66753)](https://github.com/dotnet/aspnetcore/pull/66753). (Please don't comment on closed issues and PRs.)
* <xref:blazor/components/virtualization#scroll-to-a-specific-item>
* [Add `InitialIndex` (sic&dagger;) parameter and `ScrollToIndexAsync` (sic&dagger;) API to `Virtualize<TItem>` (`dotnet/aspnetcore` #66753)](https://github.com/dotnet/aspnetcore/pull/66753). (Please don't comment on closed issues and PRs. *sic*&dagger;: API naming was changed without updating the title of the PR.)

### Automatic circuit pause on tab inactivity

Expand Down
Loading