Skip to content

Commit 63d230c

Browse files
authored
Merge pull request #36763 from dotnet/main
Approved. Merge to Live.
2 parents ce68a2c + b5bc4cc commit 63d230c

File tree

77 files changed

+1126
-1872
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1126
-1872
lines changed

aspnetcore/blazor/components/data-binding.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ As a demonstration of how data binding composes in HTML, the following example b
107107

108108
When the `BindTheory` component is rendered, the `value` of the HTML demonstration `<input>` element comes from the `InputValue` property. When the user enters a value in the text box and changes element focus, the `onchange` event is fired and the `InputValue` property is set to the changed value. In reality, code execution is more complex because [`@bind`](xref:mvc/views/razor#bind) handles cases where type conversions are performed. In general, [`@bind`](xref:mvc/views/razor#bind) associates the current value of an expression with the `value` attribute of the `<input>` and handles changes using the registered handler.
109109

110-
Bind a property or field on other DOM events by including an `@bind:event="{EVENT}"` attribute with a DOM event for the `{EVENT}` placeholder. The following example binds the `InputValue` property to the `<input>` element's value when the element's `oninput` event ([`input`](https://developer.mozilla.org/docs/Web/API/HTMLElement/input_event)) is triggered. Unlike the `onchange` event ([`change`](https://developer.mozilla.org/docs/Web/API/HTMLElement/change_event)), which fires when the element loses focus, `oninput` ([`input`](https://developer.mozilla.org/docs/Web/API/HTMLElement/input_event)) fires when the value of the text box changes.
110+
Default binding with `@bind` uses the [`change`](https://developer.mozilla.org/docs/Web/API/HTMLElement/change_event) DOM event (`onchange`). Binding can also take place on the [`input`](https://developer.mozilla.org/docs/Web/API/HTMLElement/input_event) DOM event using the `@bind:event="{EVENT}"` attribute, where the `{EVENT}` placeholder is either `oninput` or `onchange` (default).
111+
112+
The following example binds the `InputValue` property to the `<input>` element's value when the element's `oninput` event is triggered. Unlike the `onchange` event, which fires when the element loses focus, `oninput` fires when the value of the text box changes.
111113

112114
`Page/BindEvent.razor`:
113115

@@ -147,6 +149,21 @@ Bind a property or field on other DOM events by including an `@bind:event="{EVEN
147149

148150
:::moniker-end
149151

152+
:::moniker range=">= aspnetcore-6.0"
153+
154+
To bind on other DOM events, use either of the following approaches:
155+
156+
* [Delegate event handlers](xref:blazor/components/event-handling#delegate-event-handlers)
157+
* [Custom event arguments](xref:blazor/components/event-handling#custom-event-arguments)
158+
159+
:::moniker-end
160+
161+
:::moniker range="< aspnetcore-6.0"
162+
163+
To bind on other DOM events, use [delegate event handlers](xref:blazor/components/event-handling#delegate-event-handlers).
164+
165+
:::moniker-end
166+
150167
:::moniker range="< aspnetcore-7.0"
151168

152169
Razor attribute binding is case-sensitive:

aspnetcore/blazor/components/event-handling.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Specify delegate event handlers in Razor component markup with [`@on{DOM EVENT}=
2121
* The `{DOM EVENT}` placeholder is a [DOM event](https://developer.mozilla.org/docs/Web/Events) (for example, `click`).
2222
* The `{DELEGATE}` placeholder is the C# delegate event handler.
2323

24+
For supported events, see <xref:Microsoft.AspNetCore.Components.Web.EventHandlers>.
25+
2426
For event handling:
2527

2628
:::moniker range=">= aspnetcore-8.0"

aspnetcore/blazor/host-and-deploy/app-base-path.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Place the `<base>` tag in `<head>` markup ([location of `<head>` content](xref:b
141141

142142
:::moniker range=">= aspnetcore-11.0"
143143

144-
In many hosting scenarios, the relative URL path to the app is the root of the app. When the app runs at `/`, `<BasePath />` renders `<base href="/" />` automatically in [`<head>` content](xref:blazor/project-structure#location-of-head-and-body-content). For any other deployment path, the component emits a `<base>` element that matches the current request's path base.
144+
In many hosting scenarios, the relative URL path to the app is the root of the app. When the app runs at `/`, the `BasePath` component (`<BasePath />`) renders `<base href="/" />` automatically in [`<head>` content](xref:blazor/project-structure#location-of-head-and-body-content). For any other deployment path, the component emits a `<base>` element that matches the current request's path base.
145145

146146
:::moniker-end
147147

@@ -244,7 +244,7 @@ In many hosting scenarios, the relative URL path to the app is the root of the a
244244
:::moniker-end
245245

246246
> [!NOTE]
247-
> When using <xref:Microsoft.AspNetCore.Builder.WebApplication> (see <xref:migration/50-to-60#new-hosting-model>), [`app.UseRouting`](xref:Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseRouting%2A) must be called after <xref:Microsoft.AspNetCore.Builder.UsePathBaseExtensions.UsePathBase%2A> so that the Routing Middleware can observe the modified path before matching routes. Otherwise, routes are matched before the path is rewritten by <xref:Microsoft.AspNetCore.Builder.UsePathBaseExtensions.UsePathBase%2A> as described in the [Middleware Ordering](xref:fundamentals/middleware/index#order) and [Routing](xref:fundamentals/routing) articles.
247+
> When using <xref:Microsoft.AspNetCore.Builder.WebApplication> (see <xref:migration/50-to-60#new-hosting-model>), [`app.UseRouting`](xref:Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseRouting%2A) must be called after <xref:Microsoft.AspNetCore.Builder.UsePathBaseExtensions.UsePathBase%2A> so that the Routing Middleware can observe the modified path before matching routes. Otherwise, routes are matched before the path is rewritten by <xref:Microsoft.AspNetCore.Builder.UsePathBaseExtensions.UsePathBase%2A> as described in the <xref:fundamentals/middleware/index#middleware-order> and <xref:fundamentals/routing>.
248248
249249
Don't prefix links throughout the app with a forward slash. Either avoid the use of a path segment separator or use dot-slash (`./`) relative path notation:
250250

aspnetcore/blazor/security/webassembly/microsoft-entra-id-groups-and-roles-net-5-to-7.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
613613
> [!NOTE]
614614
> If you prefer to use the `wids` claim (ADD Administrator Roles), assign "`wids`" to the <xref:Microsoft.IdentityModel.Tokens.TokenValidationParameters.RoleClaimType?displayProperty=nameWithType>.
615615
616-
After you've completed the preceding steps to create and assign roles to users (or groups if you have a Premium tier Azure account) and implemented the `CustomAccountFactory` with the Graph SDK, as explained earlier in this article and in <xref:blazor/security/webassembly/graph-api?pivots=graph-sdk>, you should see an `appRole` claim for each assigned role that a signed-in user is assigned (or roles assigned to groups that they are members of). Run the app with a test user to confirm the claim(s) are present as expected. When testing with the Graph SDK locally, we recommend using a new in-private/incognito browser session for each test to prevent lingering cookies from interfering with tests. For more information, see <xref:blazor/security/webassembly/standalone-with-microsoft-entra-id#troubleshoot>.
616+
After you've completed the preceding steps to create and assign roles to users (or groups if you have a Premium tier Azure account) and implemented the `CustomAccountFactory` with the Graph SDK, as explained earlier in this article and in <xref:blazor/security/webassembly/graph-api?pivots=graph-sdk>, you should see an `appRole` claim for each assigned role that a signed-in user is assigned (or roles assigned to groups that they are members of). Run the app with a test user to confirm the claims are present as expected. When testing with the Graph SDK locally, we recommend using a new in-private/incognito browser session for each test to prevent lingering cookies from interfering with tests. For more information, see <xref:blazor/security/webassembly/standalone-with-microsoft-entra-id#troubleshoot>.
617617

618618
Component authorization approaches are functional at this point. Any of the authorization mechanisms in components of the **CLIENT** app can use the `Admin` role to authorize the user:
619619

aspnetcore/data/ef-rp/update-related-data.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ Update `Pages/Courses/Create.cshtml.cs` with the following code:
4646

4747
[!code-csharp[](intro/samples/cu50/Pages/Courses/Create.cshtml.cs?highlight=7,18,27-41)]
4848

49-
[!INCLUDE[loc comments](~/includes/code-comments-loc.md)]
50-
5149
The preceding code:
5250

5351
* Derives from `DepartmentNamePageModel`.
@@ -269,8 +267,6 @@ Update `Pages/Courses/Create.cshtml.cs` with the following code:
269267

270268
[!code-csharp[](intro/samples/cu30/Pages/Courses/Create.cshtml.cs?highlight=7,18,27-41)]
271269

272-
[!INCLUDE[about the series](~/includes/code-comments-loc.md)]
273-
274270
The preceding code:
275271

276272
* Derives from `DepartmentNamePageModel`.

aspnetcore/data/entity-framework-6.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ This sample can be created from scratch by the following steps in Visual Studio:
9696

9797
* In the Core project, in `appsettings.json`, add the connection string.
9898

99-
* In the Core project, add a controller and view(s) to verify that you can read and write data. (Note that ASP.NET Core MVC scaffolding won't work with the EF6 context referenced from the class library.)
99+
* In the Core project, add a controller and views to verify that you can read and write data. (Note that ASP.NET Core MVC scaffolding won't work with the EF6 context referenced from the class library.)
100100

101101
:::moniker-end

aspnetcore/fundamentals/app-state.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The following code shows how to set up the in-memory session provider with a def
9292

9393
The preceding code sets a short timeout to simplify testing.
9494

95-
The order of middleware is important. Call `UseSession` after `UseRouting` and before `MapRazorPages` and `MapDefaultControllerRoute` . See [Middleware Ordering](xref:fundamentals/middleware/index#order).
95+
The order of middleware is important. Call `UseSession` after `UseRouting` and before `MapRazorPages` and `MapDefaultControllerRoute`. See [Middleware Ordering](xref:fundamentals/middleware/index#middleware-order).
9696

9797
[HttpContext.Session](xref:Microsoft.AspNetCore.Http.HttpContext.Session) is available after session state is configured.
9898

@@ -376,7 +376,7 @@ The following code shows how to set up the in-memory session provider with a def
376376

377377
The preceding code sets a short timeout to simplify testing.
378378

379-
The order of middleware is important. Call `UseSession` after `UseRouting` and before `UseEndpoints`. See [Middleware Ordering](xref:fundamentals/middleware/index#order).
379+
The order of middleware is important. Call `UseSession` after `UseRouting` and before `UseEndpoints`. For more information, see <xref:fundamentals/middleware/index#middleware-order>.
380380

381381
[HttpContext.Session](xref:Microsoft.AspNetCore.Http.HttpContext.Session) is available after session state is configured.
382382

aspnetcore/fundamentals/configuration/index.md

Lines changed: 44 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
title: Configuration in ASP.NET Core
3+
ai-usage: ai-assisted
34
author: tdykstra
45
description: Learn how to use the Configuration API to configure app settings in an ASP.NET Core app.
56
monikerRange: '>= aspnetcore-3.1'
67
ms.author: tdykstra
78
ms.custom: mvc
8-
ms.date: 01/23/2026
9+
ms.date: 02/11/2026
910
uid: fundamentals/configuration/index
1011
---
1112
# Configuration in ASP.NET Core
@@ -1063,8 +1064,6 @@ Host.CreateDefaultBuilder(args)
10631064

10641065
::: moniker-end
10651066

1066-
For an additional example that uses a <xref:Microsoft.Extensions.Configuration.Memory.MemoryConfigurationProvider>, see the [Bind an array](#bind-an-array) section.
1067-
10681067
## Kestrel endpoint configuration
10691068

10701069
Kestrel-specific endpoint configuration overrides all [cross-server](xref:fundamentals/servers/index) endpoint configurations. Cross-server endpoint configurations include:
@@ -1230,7 +1229,7 @@ The <xref:Microsoft.Extensions.Configuration.ConfigurationBinder.Bind%2A?display
12301229

12311230
A configuration provider is added for `array.json` by calling [`AddJsonFile`](#json-configuration-provider).
12321231

1233-
The following code reads the configuration values:
1232+
The following code reads the configuration values.
12341233

12351234
`ArrayExample.cs`:
12361235

@@ -1249,8 +1248,6 @@ if (array is null)
12491248
throw new ArgumentNullException(nameof(array));
12501249
}
12511250

1252-
string output = String.Empty;
1253-
12541251
for (int j = 0; j < array.Entries?.Length; j++)
12551252
{
12561253
Console.WriteLine($"Index: {j} Value: {array.Entries[j]}");
@@ -1269,171 +1266,72 @@ Index: 4 Value: value50
12691266

12701267
In the preceding output, Index 3 has value `value40`, corresponding to `"4": "value40",` in `array.json`. The bound array indices are continuous and not bound to the configuration key index. The configuration binder isn't capable of binding `null` values or creating `null` entries in bound objects.
12711268

1272-
:::moniker range="< aspnetcore-6.0"
1269+
The missing configuration item for Index 3 can be supplied before binding to the `ArrayExample` instance by any configuration provider that reads the Index 3 key/value pair. In the following example, assume that the values provided by `array.json` in the preceding example are provided by an [in-memory collection](#memory-configuration-provider). The example shows how to load the Index 3 value from the [JSON Configuration Provider](#json-configuration-provider) before the collection is bound.
12731270

1274-
The following code loads the `array:entries` configuration with the <xref:Microsoft.Extensions.Configuration.MemoryConfigurationBuilderExtensions.AddInMemoryCollection%2A> extension method:
1271+
`value3.json`:
12751272

1276-
```csharp
1277-
public class Program
1273+
```json
12781274
{
1279-
public static void Main(string[] args)
1280-
{
1281-
CreateHostBuilder(args).Build().Run();
1282-
}
1283-
1284-
public static IHostBuilder CreateHostBuilder(string[] args)
1285-
{
1286-
var arrayDict = new Dictionary<string, string>
1287-
{
1288-
{"array:entries:0", "value0"},
1289-
{"array:entries:1", "value1"},
1290-
{"array:entries:2", "value2"},
1291-
// 3 Skipped
1292-
{"array:entries:4", "value4"},
1293-
{"array:entries:5", "value5"}
1294-
};
1295-
1296-
return Host.CreateDefaultBuilder(args)
1297-
.ConfigureAppConfiguration((hostingContext, config) =>
1298-
{
1299-
config.AddInMemoryCollection(arrayDict);
1300-
})
1301-
.ConfigureWebHostDefaults(webBuilder =>
1302-
{
1303-
webBuilder.UseStartup<Startup>();
1304-
});
1305-
}
1275+
"array:entries:3": "value30"
13061276
}
13071277
```
13081278

1309-
The following code reads the configuration in the `arrayDict` `Dictionary` and displays the values:
1279+
::: moniker range=">= aspnetcore-6.0"
13101280

13111281
```csharp
1312-
public class ArrayModel : PageModel
1282+
var configSettings = new Dictionary<string, string>
13131283
{
1314-
private readonly IConfiguration Config;
1315-
public ArrayExample _array { get; private set; }
1316-
1317-
public ArrayModel(IConfiguration config)
1318-
{
1319-
Config = config;
1320-
}
1321-
1322-
public ContentResult OnGet()
1323-
{
1324-
_array = Config.GetSection("array").Get<ArrayExample>();
1325-
string s = null;
1326-
1327-
for (int j = 0; j < _array.Entries.Length; j++)
1328-
{
1329-
s += $"Index: {j} Value: {_array.Entries[j]} \n";
1330-
}
1331-
1332-
return Content(s);
1333-
}
1334-
}
1335-
```
1336-
1337-
The preceding code returns the following output:
1284+
{ "array:entries:0", "value00" },
1285+
{ "array:entries:1", "value10" },
1286+
{ "array:entries:2", "value20" },
1287+
{ "array:entries:4", "value40" },
1288+
{ "array:entries:5", "value50" }
1289+
};
13381290

1339-
```text
1340-
Index: 0 Value: value0
1341-
Index: 1 Value: value1
1342-
Index: 2 Value: value2
1343-
Index: 3 Value: value4
1344-
Index: 4 Value: value5
1291+
builder.Configuration.AddInMemoryCollection(configSettings);
1292+
builder.Configuration.AddJsonFile("value3.json", optional: false,
1293+
reloadOnChange: false);
13451294
```
13461295

1347-
Index &num;3 in the bound object holds the configuration data for the `array:4` configuration key and its value of `value4`. When configuration data containing an array is bound, the array indices in the configuration keys are used to iterate the configuration data when creating the object. A null value can't be retained in configuration data, and a null-valued entry isn't created in a bound object when an array in configuration keys skip one or more indices.
1348-
1349-
The missing configuration item for index &num;3 can be supplied before binding to the `ArrayExample` instance by any configuration provider that reads the index &num;3 key/value pair. Consider the following `Value3.json` file from the sample download:
1350-
1351-
```json
1352-
{
1353-
"array:entries:3": "value3"
1354-
}
1355-
```
1296+
::: moniker-end
13561297

1357-
The following code includes configuration for `Value3.json` and the `arrayDict` `Dictionary`:
1298+
::: moniker range="< aspnetcore-6.0"
13581299

13591300
```csharp
1360-
public class Program
1361-
{
1362-
public static void Main(string[] args)
1363-
{
1364-
CreateHostBuilder(args).Build().Run();
1365-
}
1366-
1367-
public static IHostBuilder CreateHostBuilder(string[] args)
1301+
Host.CreateDefaultBuilder(args)
1302+
.ConfigureWebHostDefaults(webBuilder =>
13681303
{
1369-
var arrayDict = new Dictionary<string, string>
1304+
webBuilder.UseStartup<Startup>();
1305+
})
1306+
.ConfigureAppConfiguration(config =>
1307+
{
1308+
var configSettings = new Dictionary<string, string>
13701309
{
1371-
{"array:entries:0", "value0"},
1372-
{"array:entries:1", "value1"},
1373-
{"array:entries:2", "value2"},
1374-
// 3 Skipped
1375-
{"array:entries:4", "value4"},
1376-
{"array:entries:5", "value5"}
1310+
{ "array:entries:0", "value00" },
1311+
{ "array:entries:1", "value10" },
1312+
{ "array:entries:2", "value20" },
1313+
{ "array:entries:4", "value40" },
1314+
{ "array:entries:5", "value50" }
13771315
};
13781316

1379-
return Host.CreateDefaultBuilder(args)
1380-
.ConfigureAppConfiguration((hostingContext, config) =>
1381-
{
1382-
config.AddInMemoryCollection(arrayDict);
1383-
config.AddJsonFile("Value3.json",
1384-
optional: false, reloadOnChange: false);
1385-
})
1386-
.ConfigureWebHostDefaults(webBuilder =>
1387-
{
1388-
webBuilder.UseStartup<Startup>();
1389-
});
1390-
}
1391-
}
1317+
config.AddInMemoryCollection(configSettings);
1318+
config.AddJsonFile("value3.json", optional: false, reloadOnChange: false);
1319+
});
13921320
```
13931321

1394-
The following code reads the preceding configuration and displays the values:
1395-
1396-
```csharp
1397-
public class ArrayModel : PageModel
1398-
{
1399-
private readonly IConfiguration Config;
1400-
public ArrayExample _array { get; private set; }
1401-
1402-
public ArrayModel(IConfiguration config)
1403-
{
1404-
Config = config;
1405-
}
1406-
1407-
public ContentResult OnGet()
1408-
{
1409-
_array = Config.GetSection("array").Get<ArrayExample>();
1410-
string s = null;
1411-
1412-
for (int j = 0; j < _array.Entries.Length; j++)
1413-
{
1414-
s += $"Index: {j} Value: {_array.Entries[j]} \n";
1415-
}
1416-
1417-
return Content(s);
1418-
}
1419-
}
1420-
```
1322+
:::moniker-end
14211323

1422-
The preceding code returns the following output:
1324+
The preceding code results in the following bound array:
14231325

1424-
```text
1425-
Index: 0 Value: value0
1426-
Index: 1 Value: value1
1427-
Index: 2 Value: value2
1428-
Index: 3 Value: value3
1429-
Index: 4 Value: value4
1430-
Index: 5 Value: value5
1326+
```console
1327+
Index: 0 Value: value00
1328+
Index: 1 Value: value10
1329+
Index: 2 Value: value20
1330+
Index: 3 Value: value30
1331+
Index: 4 Value: value40
1332+
Index: 5 Value: value50
14311333
```
14321334

1433-
Custom configuration providers aren't required to implement array binding.
1434-
1435-
:::moniker-end
1436-
14371335
## Custom configuration provider
14381336

14391337
The sample app demonstrates how to create a basic configuration provider that reads configuration key-value pairs from a database using [Entity Framework (EF)](/ef/core/).

aspnetcore/fundamentals/http-requests.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ Typed clients:
890890
A typed client accepts an `HttpClient` parameter in its constructor:
891891

892892
:::code language="csharp" source="http-requests/samples/3.x/HttpClientFactorySample/GitHub/GitHubService.cs" id="snippet1" highlight="5":::
893-
[!INCLUDE[about the series](~/includes/code-comments-loc.md)]
894893

895894
In the preceding code:
896895

aspnetcore/fundamentals/localization/includes/localization35.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ The current culture on a request is set in the localization [Middleware](xref:fu
255255

256256
[!code-csharp[](~/fundamentals/localization/sample/3.x/Localization/Startup.cs?name=snippet2)]
257257

258-
[!INCLUDE[about the series](~/includes/code-comments-loc.md)]
259-
260258
`UseRequestLocalization` initializes a `RequestLocalizationOptions` object. On every request the list of `RequestCultureProvider` in the `RequestLocalizationOptions` is enumerated and the first provider that can successfully determine the request culture is used. The default providers come from the `RequestLocalizationOptions` class:
261259

262260
1. `QueryStringRequestCultureProvider`

0 commit comments

Comments
 (0)