Skip to content

Commit fffcdbf

Browse files
authored
[11.0 P1] Blazor release notes and initial migration guidance (#36449)
1 parent 7e9b605 commit fffcdbf

5 files changed

Lines changed: 242 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* [Visual Studio](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.
2+
3+
![VS22 installer workloads](~/tutorials/min-web-api/_static/asp-net-web-dev.png)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* [Visual Studio Code](https://code.visualstudio.com/download)
2+
* [C# Dev Kit for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit)
3+
* [!INCLUDE [](~/includes/0-latest-SDK.md)]
4+
5+
You can follow the Visual Studio Code instructions on macOS, Linux, or Windows. Changes may be required if you use an integrated development environment (IDE) other than Visual Studio Code.

aspnetcore/migration/100-to-110.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: Migrate from ASP.NET Core in .NET 10 to ASP.NET Core in .NET 11
3+
author: wadepickett
4+
description: Learn how to migrate an ASP.NET Core in .NET 10 to ASP.NET Core in .NET 11.
5+
ms.author: wpickett
6+
ms.date: 01/26/2026
7+
uid: migration/100-to-110
8+
---
9+
# Migrate from ASP.NET Core in .NET 10 to ASP.NET Core in .NET 11
10+
11+
<!-- New content should be added to the includes files in the '100-to-110' folder. This will help prevent merge conflicts in this file. -->
12+
13+
This article explains how to update an ASP.NET Core in .NET 10 to ASP.NET Core in .NET 10.
14+
15+
## Prerequisites
16+
17+
# [Visual Studio](#tab/visual-studio)
18+
19+
[!INCLUDE[](~/includes/net-prereqs-vs-11-latest.md)]
20+
21+
# [Visual Studio Code](#tab/visual-studio-code)
22+
23+
[!INCLUDE[](~/includes/net-prereqs-vsc-11.md)]
24+
25+
---
26+
27+
## Update the .NET SDK version in `global.json`
28+
29+
If you rely on a [`global.json`](/dotnet/core/tools/global-json) file to target a specific .NET SDK version, update the `version` property to the .NET 11 SDK version that's installed. For example:
30+
31+
```diff
32+
{
33+
"sdk": {
34+
- "version": "10.0.102"
35+
+ "version": "11.0.100"
36+
}
37+
}
38+
```
39+
40+
## Update the target framework
41+
42+
Update the project file's [Target Framework Moniker (TFM)](/dotnet/standard/frameworks) to `net11.0`:
43+
44+
```diff
45+
<Project Sdk="Microsoft.NET.Sdk.Web">
46+
47+
<PropertyGroup>
48+
- <TargetFramework>net10.0</TargetFramework>
49+
+ <TargetFramework>net11.0</TargetFramework>
50+
</PropertyGroup>
51+
52+
</Project>
53+
```
54+
55+
## Update package references
56+
57+
In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.org/packages?q=Microsoft.AspNetCore.*), [`Microsoft.EntityFrameworkCore.*`](https://www.nuget.org/packages?q=Microsoft.EntityFrameworkCore.*), [`Microsoft.Extensions.*`](https://www.nuget.org/packages?q=Microsoft.Extensions.*), and [`System.Net.Http.Json`](https://www.nuget.org/packages/System.Net.Http.Json) package reference's `Version` attribute to 11.0.0 or later. For example:
58+
59+
```diff
60+
<ItemGroup>
61+
- <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="10.0.0" />
62+
- <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.0" />
63+
- <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.0" />
64+
- <PackageReference Include="System.Net.Http.Json" Version="10.0.0" />
65+
+ <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="11.0.0" />
66+
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="11.0.0" />
67+
+ <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="11.0.0" />
68+
+ <PackageReference Include="System.Net.Http.Json" Version="11.0.0" />
69+
</ItemGroup>
70+
```
71+
72+
## Blazor
73+
74+
[!INCLUDE[](~/migration/100-to-110/includes/blazor.md)]
75+
76+
## Breaking changes
77+
78+
Use the articles in [Breaking changes in .NET](/dotnet/core/compatibility/breaking-changes) to find breaking changes that might apply when upgrading an app to a newer version of .NET.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### Blazor release notes
2+
3+
For new feature coverage, see <xref:aspnetcore-11>.
4+
5+
### Adopt Inline JS event handler removed from the `NavMenu` component
6+
7+
*This section only applies to Blazor Web Apps.*
8+
9+
The inline JS event handler for the navigation bar toggler isn't present in the `NavMenu` component of the Blazor Web App project template in .NET 11 or later. Apps generated from the project template use a [collocated JS module](xref:blazor/js-interop/javascript-location#load-a-script-from-an-external-javascript-file-js-collocated-with-a-component) approach to show or hide the navigation links on the rendered page. The approach improves [Content Security Policy (CSP) compliance](xref:blazor/security/content-security-policy) because it doesn't require the CSP to include an unsafe hash for the inline JS.
10+
11+
Use the following instructions to adopt the new JS module approach for the navigation links toggler in an existing app.
12+
13+
Add a [collocated JS module](xref:blazor/js-interop/javascript-location#load-a-script-from-an-external-javascript-file-js-collocated-with-a-component) next to the app's `NavMenu` component.
14+
15+
`NavMenu.razor.js`:
16+
17+
```javascript
18+
// Handle navigation menu toggle
19+
const navScrollable = document.getElementById("nav-scrollable");
20+
const navToggler = document.querySelector(".navbar-toggler");
21+
22+
if (navScrollable && navToggler) {
23+
navScrollable.addEventListener("click", function() {
24+
navToggler.click();
25+
});
26+
}
27+
```
28+
29+
At the top of the app's `NavMenu` component (`NavMenu.razor`), add a `<script>` tag for the collocated JS module:
30+
31+
* If the app adopts client-side rendering (has a `.Client` project) with global interactivity (the render mode is set globally for the app by the app's `App` component), use the following tag, which indicates the path to the module in the `Layout` folder:
32+
33+
```razor
34+
<script type="module" src="@Assets["Layout/NavMenu.razor.js"]"></script>
35+
```
36+
37+
* Otherwise, use the following tag, which indicates the path to the module in the `Components/Layout` folder:
38+
39+
```razor
40+
<script type="module" src="@Assets["Components/Layout/NavMenu.razor.js"]"></script>
41+
```
42+
43+
Also in the app's `NavMenu` component, change the line that has the inline JS to toggle the navigation links:
44+
45+
```diff
46+
- <div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
47+
+ <div id="nav-scrollable" class="nav-scrollable">
48+
```
49+
50+
If the app has a [Content Security Policy (CSP)](xref:blazor/security/content-security-policy#server-side-blazor-apps) with an unsafe hash for the inline JS removed by the preceding step, remove the unsafe hash:
51+
52+
```diff
53+
- 'unsafe-hashes' 'sha256-qnHnQs7NjQNHHNYv/I9cW+I62HzDJjbnyS/OFzqlix0='
54+
```
Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,102 @@
1-
*Release notes appear in this section as preview features become available.*
1+
### New `DisplayName` component and support for `[Display]` and `[DisplayName]` attributes
2+
3+
<!-- UPDATE 11.0 - API cross-link
4+
5+
<xref:Microsoft.AspNetCore.Components.Forms.DisplayName%601>
6+
-->
7+
The `DisplayName` component can be used to display property names from metadata attributes:
8+
9+
```csharp
10+
[Required, DisplayName("Production Date")]
11+
public DateTime ProductionDate { get; set; }
12+
```
13+
14+
The [`[Display]` attribute](xref:System.ComponentModel.DataAnnotations.DisplayAttribute) on the model class property is supported:
15+
16+
```csharp
17+
[Required, Display(Name = "Production Date")]
18+
public DateTime ProductionDate { get; set; }
19+
```
20+
21+
Of the two approaches, the `[Display]` attribute is recommended, which makes additional properties available. The `[Display]` attribute also enables assigning a resource type for localization. When both attributes are present, `[Display]` takes precedence over `[DisplayName]`. If neither attribute is present, the component falls back to the property name.
22+
23+
Use the `DisplayName` component in labels or table headers:
24+
25+
```razor
26+
<label>
27+
<DisplayName For="@(() => Model!.ProductionDate)" />
28+
<InputDate @bind-Value="Model!.ProductionDate" />
29+
</label>
30+
```
31+
32+
### Blazor Web script startup options format now supported for Blazor Server and Blazor WebAssembly scripts
33+
34+
The Blazor Web App script (`blazor.web.js`) options object passed to `Blazor.start()` uses the following format since the release of .NET 8:
35+
36+
```javascript
37+
Blazor.start({
38+
ssr: { ... },
39+
circuit: { ... },
40+
webAssembly: { ... },
41+
});
42+
```
43+
44+
Now, Blazor Server (`blazor.server.js`) and Blazor WebAssembly (`blazor.webassembly.js`) scripts can use the same options format.
45+
46+
The following example shows the prior options format, which remains supported:
47+
48+
```javascript
49+
Blazor.start({
50+
loadBootResource: function (...) {
51+
...
52+
},
53+
});
54+
```
55+
56+
The newly supported options format for the preceding example:
57+
58+
```javascript
59+
Blazor.start({
60+
webAssembly: {
61+
loadBootResource: function (...) {
62+
...
63+
},
64+
},
65+
});
66+
```
67+
68+
For more information, see <xref:blazor/fundamentals/startup?view=aspnetcore-11.0#startup-process-and-configuration>.
69+
70+
### New `BasePath` component
71+
72+
Blazor Web Apps can use the new `BasePath` component (`<BasePath />`) to render the app's app base path (`<base href>`) HTML tag automatically. For more information, see <xref:blazor/host-and-deploy/app-base-path?view=aspnetcore-11.0>.
73+
74+
### Inline JS event handler removed from the `NavMenu` component
75+
76+
The inline JS event handler that toggles the display of navigation links is no longer present in the `NavMenu` component of the Blazor Web App project template. Apps generated from the project template now use a [collocated JS module](xref:blazor/js-interop/javascript-location?view=aspnetcore-11.0#load-a-script-from-an-external-javascript-file-js-collocated-with-a-component) approach to show or hide the navigation bar on the rendered page. The new approach improves [Content Security Policy (CSP) compliance](xref:blazor/security/content-security-policy?view=aspnetcore-11.0) because it doesn't require the CSP to include an unsafe hash for the inline JS.
77+
78+
To migrate an existing app to .NET 11, including adopting the new JS module approach for the navigation bar toggler, see <xref:migration/100-to-110>.
79+
80+
### `NavigateTo` and `NavLink` support for relative navigation
81+
82+
The new `RelativeToCurrentUri` parameter (default: `false`) for <xref:Microsoft.AspNetCore.Components.NavigationManager.NavigateTo%2A?displayProperty=nameWithType> and the [`NavLink` component](xref:blazor/fundamentals/routing?view=aspnetcore-11.0#navlink-component) allows you to navigate to URIs relative to the current page path rather than the app's base URI.
83+
84+
Consider the following nested endpoints:
85+
86+
* `/docs`
87+
* `/getting-started`
88+
* `/installation`
89+
* `/configuration`
90+
91+
When the browser's URI is `/docs/getting-started/installation` and you want to navigate the user to `/docs/getting-started/configuration`, `NavigateTo("/configuration")` redirects to `/configuration` at the app's root instead of the relative path at `/docs/getting-started/configuration`. Set the `RelativeToCurrentUri` with <xref:Microsoft.AspNetCore.Components.NavigationManager.NavigateTo%2A> or the [`NavLink` component](xref:blazor/fundamentals/routing?view=aspnetcore-11.0#navlink-component) for the desired navigation:
92+
93+
```csharp
94+
Navigation.NavigateTo("/configuration", new NavigationOptions
95+
{
96+
RelativeToCurrentUri = true
97+
});
98+
```
99+
100+
```razor
101+
<NavLink href="configuration" RelativeToCurrentUri="true">Configuration</NavLink>
102+
```

0 commit comments

Comments
 (0)