Skip to content

Commit 415ca87

Browse files
Merge branch 'dotnet:main' into main
2 parents 6a9d124 + c429bad commit 415ca87

File tree

42 files changed

+1990
-1149
lines changed

Some content is hidden

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

42 files changed

+1990
-1149
lines changed

.github/workflows/issue-processing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
issue_number: context.issue.number,
7878
owner: context.repo.owner,
7979
repo: context.repo.repo,
80-
body: `### 😎 **March!** ***The gateway to spring!*** 🌞
80+
body: `### 😎 **Welcome April!** ***Summertime is almost here!*** 🌞
8181
8282
A green dinosaur 🦖 will be along shortly to assist. *Stand-by ........*`
8383
})

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,11 @@
12771277
"source_path": "aspnetcore/blazor/security/server/blazor-web-app-with-oidc.md",
12781278
"redirect_url": "/aspnet/core/blazor/security/blazor-web-app-with-oidc",
12791279
"redirect_document_id": false
1280+
},
1281+
{
1282+
"source_path": "aspnetcore/blazor/http-caching-issues.md",
1283+
"redirect_url": "/aspnet/core/blazor/host-and-deploy/webassembly-caching/http-caching-issues",
1284+
"redirect_document_id": false
12801285
}
12811286
]
12821287
}

aspnetcore/blazor/call-web-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ public class CookieHandler : DelegatingHandler
680680
The `CookieHandler` is registered in the `Program` file:
681681

682682
```csharp
683-
builder.Services.AddScoped<CookieHandler>();
683+
builder.Services.AddTransient<CookieHandler>();
684684
```
685685

686686
The message handler is added to any preconfigured <xref:System.Net.Http.HttpClient> that requires cookie authentication:

aspnetcore/blazor/components/dynamiccomponent.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ In the following example, a Razor component renders a component based on the use
143143

144144
In the preceding example:
145145

146-
* Component names are used as the option values using the [`nameof` operator](/dotnet/csharp/language-reference/operators/nameof), which returns component names as constant strings.
147-
* The namespace of the app is `BlazorSample`. ***Change the namespace to match your app's namespace.***
146+
* An <xref:System.Collections.Generic.Dictionary%602> is used to manage components to be displayed.
147+
* Names serve as the dictionary keys and are provided as selection options.
148+
* Component types are stored as dictionary values using the [`typeof` operator](/dotnet/csharp/language-reference/operators/type-testing-and-cast#typeof-operator).
148149

149150
## Pass parameters
150151

@@ -197,7 +198,7 @@ The following `RocketLabWithWindowSeat` component (`RocketLabWithWindowSeat.razo
197198
In the following example:
198199

199200
* Only the `RocketLabWithWindowSeat` component's parameter for a window seat (`WindowSeat`) receives the value of the **`Window Seat`** checkbox.
200-
* The namespace of the app is `BlazorSample`. ***Change the namespace to match your app's namespace.***
201+
* Component names are used as dictionary keys using the [`nameof` operator](/dotnet/csharp/language-reference/operators/nameof), which returns component names as constant strings.
201202
* The dynamically-rendered components are shared components:
202203
* Shown in this article section: `RocketLabWithWindowSeat` (`RocketLabWithWindowSeat.razor`)
203204
* Components shown in the [Example](#example) section earlier in this article:
@@ -340,10 +341,7 @@ In the following parent component example, the `ShowDTMessage` method assigns a
340341
The parent component passes the callback method, `ShowDTMessage` in the parameter dictionary:
341342

342343
* The `string` key is the callback method's name, `OnClickCallback`.
343-
* The `object` value is created by <xref:Microsoft.AspNetCore.Components.EventCallbackFactory.Create%2A?displayProperty=nameWithType> for the parent callback method, `ShowDTMessage`. Note that the [`this` keyword](/dotnet/csharp/language-reference/keywords/this) isn't supported in C# fields, so a C# property is used for the parameter dictionary.
344-
345-
> [!IMPORTANT]
346-
> For the following component, modify the code in the `OnDropdownChange` method. Change the namespace name of "`BlazorSample`" in the `Type.GetType()` argument to match your app's namespace.
344+
* The `object` value is created by <xref:Microsoft.AspNetCore.Components.EventCallbackFactory.Create%2A?displayProperty=nameWithType> for the parent callback method, `ShowDTMessage`. Note that the [`this` keyword](/dotnet/csharp/language-reference/keywords/this) isn't supported in C# field initialization, so a C# property is used for the parameter dictionary.
347345

348346
:::moniker range=">= aspnetcore-8.0"
349347

aspnetcore/blazor/components/rendering.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Components inherited from <xref:Microsoft.AspNetCore.Components.ComponentBase> s
3333

3434
[!INCLUDE[](~/includes/aspnetcore-repo-ref-source-links.md)]
3535

36-
* The component's [`ShouldRender` method](#suppress-ui-refreshing-shouldrender) returns `false`.
36+
* The override of the component's [`ShouldRender` method](#suppress-ui-refreshing-shouldrender) returns `false` (the default `ComponentBase` implementation always returns `true`).
3737

3838
## Control the rendering flow
3939

@@ -256,9 +256,9 @@ One way to deal with this scenario is to provide a *state management* class, oft
256256

257257
For approaches to manage state, see the following resources:
258258

259-
* [Server-side in-memory state container service](xref:blazor/state-management?pivots=server#in-memory-state-container-service-server) ([client-side equivalent](xref:blazor/state-management?pivots=webassembly#in-memory-state-container-service-wasm)) section of the *State management* article.
260-
* [Pass data across a component hierarchy](xref:blazor/components/cascading-values-and-parameters#pass-data-across-a-component-hierarchy) using cascading values and parameters.
261259
* [Bind across more than two components](xref:blazor/components/data-binding#bind-across-more-than-two-components) using data bindings.
260+
* [Pass data across a component hierarchy](xref:blazor/components/cascading-values-and-parameters#pass-data-across-a-component-hierarchy) using cascading values and parameters.
261+
* [Server-side in-memory state container service](xref:blazor/state-management?pivots=server#in-memory-state-container-service-server) ([client-side equivalent](xref:blazor/state-management?pivots=webassembly#in-memory-state-container-service-wasm)) section of the *State management* article.
262262

263263
For the state manager approach, C# events are outside the Blazor rendering pipeline. Call <xref:Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged%2A> on other components you wish to rerender in response to the state manager's events.
264264

aspnetcore/blazor/components/virtualization.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ If the collection contains thousands of flights, rendering the flights takes a l
4646
Instead of rendering the entire list of flights at once, replace the [`foreach`](/dotnet/csharp/language-reference/keywords/foreach-in) loop in the preceding example with the <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component:
4747

4848
* Specify `allFlights` as a fixed item source to <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601.Items%2A?displayProperty=nameWithType>. Only the currently visible flights are rendered by the <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component.
49+
50+
If a non-generic collection supplies the items, for example a collection of <xref:System.Data.DataRow>, follow the guidance in the [Item provider delegate](#item-provider-delegate) section to supply the items.
4951
* Specify a context for each flight with the `Context` parameter. In the following example, `flight` is used as the context, which provides access to each flight's members.
5052

5153
```razor
@@ -70,8 +72,7 @@ The <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> com
7072

7173
* Calculates the number of items to render based on the height of the container and the size of the rendered items.
7274
* Recalculates and rerenders the items as the user scrolls.
73-
* Only fetches the slice of records from an external API that correspond to the current visible region, instead of downloading all of the data from the collection.
74-
* Receives a generic <xref:System.Collections.Generic.ICollection%601> for <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601.Items?displayProperty=nameWithType>. If a non-generic collection supplies the items (for example, a collection of <xref:System.Data.DataRow>), follow the guidance in the [Item provider delegate](#item-provider-delegate) section to supply the items.
75+
* Only fetches the slice of records from an external API that correspond to the currently visible region, including overscan, when `ItemsProvider` is used instead of `Items` (see the [Item provider delegate](#item-provider-delegate) section).
7576

7677
The item content for the <xref:Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize%601> component can include:
7778

aspnetcore/blazor/fundamentals/environments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Obtain the app's environment in a component by injecting <xref:Microsoft.AspNetC
186186
187187
<h1>Environment example</h1>
188188
189-
<p>Environment: @HostEnvironment.Environment</p>
189+
<p>Environment: @Env.Environment</p>
190190
```
191191

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

aspnetcore/blazor/fundamentals/routing.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,71 @@ The following HTML markup is rendered:
16091609
> }
16101610
> ```
16111611
1612+
<xref:Microsoft.AspNetCore.Components.Routing.NavLink> component entries can be dynamically created from the app's components via reflection. The following example demonstrates the general approach for further customization.
1613+
1614+
For the following demonstration, a consistent, standard naming convention is used for the app's components:
1615+
1616+
* Routable component file names use Pascal case&dagger;, for example `Pages/ProductDetail.razor`.
1617+
* Routable component file paths match their URLs in kebab case&Dagger; with hyphens appearing between words in a component's route template. For example, a `ProductDetail` component with a route template of `/product-detail` (`@page "/product-detail"`) is requested in a browser at the relative URL `/product-detail`.
1618+
1619+
&dagger;Pascal case (upper camel case) is a naming convention without spaces and punctuation and with the first letter of each word capitalized, including the first word.
1620+
&Dagger;Kebab case is a naming convention without spaces and punctuation that uses lowercase letters and dashes between words.
1621+
1622+
In the Razor markup of the `NavMenu` component (`NavMenu.razor`) under the default `Home` page, <xref:Microsoft.AspNetCore.Components.Routing.NavLink> components are added from a collection:
1623+
1624+
```diff
1625+
<div class="nav-scrollable"
1626+
onclick="document.querySelector('.navbar-toggler').click()">
1627+
<nav class="flex-column">
1628+
<div class="nav-item px-3">
1629+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
1630+
<span class="bi bi-house-door-fill-nav-menu"
1631+
aria-hidden="true"></span> Home
1632+
</NavLink>
1633+
</div>
1634+
1635+
+ @foreach (var name in GetRoutableComponents())
1636+
+ {
1637+
+ <div class="nav-item px-3">
1638+
+ <NavLink class="nav-link"
1639+
+ href="@Regex.Replace(name, @"(\B[A-Z]|\d+)", "-$1").ToLower()">
1640+
+ @Regex.Replace(name, @"(\B[A-Z]|\d+)", " $1")
1641+
+ </NavLink>
1642+
+ </div>
1643+
+ }
1644+
1645+
</nav>
1646+
</div>
1647+
```
1648+
1649+
The `GetRoutableComponents` method in the `@code` block:
1650+
1651+
```csharp
1652+
public IEnumerable<string> GetRoutableComponents()
1653+
{
1654+
return Assembly.GetExecutingAssembly()
1655+
.ExportedTypes
1656+
.Where(t => t.IsSubclassOf(typeof(ComponentBase)))
1657+
.Where(c => c.GetCustomAttributes(inherit: true)
1658+
.OfType<RouteAttribute>()
1659+
.Any())
1660+
.Where(c => c.Name != "Home" && c.Name != "Error")
1661+
.OrderBy(o => o.Name)
1662+
.Select(c => c.Name);
1663+
}
1664+
```
1665+
1666+
The preceding example doesn't include the following pages in the rendered list of components:
1667+
1668+
* `Home` page: The page is listed separately from the automatically generated links because it should appear at the top of the list and set the `Match` parameter.
1669+
* `Error` page: The error page is only navigated to by the framework and shouldn't be listed.
1670+
1671+
:::moniker range=">= aspnetcore-8.0"
1672+
1673+
For an example of the preceding code in a sample app that you can run locally, obtain the [**Blazor Web App** or **Blazor WebAssembly** sample app](xref:blazor/fundamentals/index#sample-apps).
1674+
1675+
:::moniker-end
1676+
16121677
## ASP.NET Core endpoint routing integration
16131678

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

0 commit comments

Comments
 (0)