From f00289b40739f838279e72d9040fe57e9608f58b Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Thu, 6 Feb 2025 10:15:06 -0500 Subject: [PATCH 1/5] Blazor startup options format --- .../blazor/fundamentals/environments.md | 14 ++- aspnetcore/blazor/fundamentals/logging.md | 28 ++++- aspnetcore/blazor/fundamentals/signalr.md | 106 ++++++++++++++++-- aspnetcore/blazor/fundamentals/startup.md | 58 +++++++++- .../blazor/globalization-localization.md | 14 ++- 5 files changed, 203 insertions(+), 17 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index c233906a468c..72bac14965ec 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -68,10 +68,14 @@ For general guidance on ASP.NET Core app configuration, see ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see . Using the `environment` property overrides the environment set by the [`Blazor-Environment` header](#set-the-client-side-environment-via-header). diff --git a/aspnetcore/blazor/fundamentals/logging.md b/aspnetcore/blazor/fundamentals/logging.md index 2f76cb2c93b3..1a4ec1d84b26 100644 --- a/aspnetcore/blazor/fundamentals/logging.md +++ b/aspnetcore/blazor/fundamentals/logging.md @@ -670,10 +670,14 @@ For the `configureLogging` log level value, pass the argument as either the stri Example 1: Set the log level with a string value. -:::moniker range=">= aspnetcore-8.0" +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Server: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```html ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see . Example 2: Set the log level with an integer value. -:::moniker range=">= aspnetcore-8.0" +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Server: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```html ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see . > [!NOTE] diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index 278cdcc65a43..969debef91de 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -885,8 +885,16 @@ Configure the following values for the client: The following example for the `App.razor` file (Blazor Web App) shows the assignment of default values. +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script and the path to use, see . When creating a hub connection in a component, set the (default: 30 seconds) and (default: 15 seconds) on the . Set the (default: 15 seconds) on the built . The following example shows the assignment of default values: @@ -1010,10 +1030,14 @@ To modify the connection events, register callbacks for the following connection **Both `onConnectionDown` and `onConnectionUp` must be specified.** -:::moniker range=">= aspnetcore-8.0" +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Server: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```html ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script and the path to use, see . :::moniker range=">= aspnetcore-7.0" @@ -1080,10 +1112,14 @@ Create the following `wwwroot/boot.js` file. :::moniker-end -:::moniker range=">= aspnetcore-8.0" +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```javascript (() => { const maximumRetryCount = 3; @@ -1148,11 +1184,15 @@ Blazor Web App: })(); ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Server: :::moniker-end -:::moniker range=">= aspnetcore-7.0" +:::moniker range=">= aspnetcore-7.0 < aspnetcore-10.0" ```javascript (() => { @@ -1224,10 +1264,14 @@ For more information on Blazor startup, see . To adjust the reconnection retry count and interval, set the number of retries (`maxRetries`) and period in milliseconds permitted for each retry attempt (`retryIntervalMilliseconds`). -:::moniker range=">= aspnetcore-8.0" +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Server: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```html ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script and the path to use, see . :::moniker range=">= aspnetcore-9.0" @@ -1369,8 +1421,16 @@ The server timeout can be increased, and the Keep-Alive interval can remain the In the following [startup configuration](xref:blazor/fundamentals/startup) example ([location of the Blazor script](xref:blazor/project-structure#location-of-the-blazor-script)), a custom value of 60 seconds is used for the server timeout. The Keep-Alive interval (`withKeepAliveInterval`) isn't set and uses its default value of 15 seconds. +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Server: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + When creating a hub connection in a component, set the server timeout (, default: 30 seconds) on the . Set the (default: 15 seconds) on the built . Confirm that the timeouts are at least double the Keep-Alive interval (/) and that the Keep-Alive value matches between server and client. The following example is based on the `Index` component in the [SignalR with Blazor tutorial](xref:blazor/tutorials/signalr-blazor). The server timeout is increased to 60 seconds, and the handshake timeout is increased to 30 seconds. The Keep-Alive interval isn't set and uses its default value of 15 seconds. @@ -1535,13 +1607,17 @@ Use a to c Prevent automatically starting the app by adding `autostart="false"` to the Blazor ` -+ +- ++ + ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Server: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```diff -- -+ +- ++ + ``` +:::moniker-end + +**In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see . + Add the following call with the hub path to the middleware processing pipeline in the server app's `Program` file. :::moniker range=">= aspnetcore-8.0" diff --git a/aspnetcore/blazor/fundamentals/startup.md b/aspnetcore/blazor/fundamentals/startup.md index 09ea29ba9b94..dd85123b0085 100644 --- a/aspnetcore/blazor/fundamentals/startup.md +++ b/aspnetcore/blazor/fundamentals/startup.md @@ -41,10 +41,14 @@ For the location of the script, see ` tag. * Place a script that calls `Blazor.start()` after the Blazor ` ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Standalone Blazor WebAssembly and Blazor Server: :::moniker-end +:::moniker range="< aspnetcore-10.0" + * Add an `autostart="false"` attribute and value to the Blazor ` ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see . :::moniker range=">= aspnetcore-6.0" @@ -387,10 +399,14 @@ The `loadBootResource` function can return a URI string to override the loading The `{TARGET FRAMEWORK}` placeholder is the target framework moniker (for example, `net7.0`). The `{VERSION}` placeholder is the shared framework version (for example, `7.0.0`). -:::moniker range=">= aspnetcore-8.0" +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Standalone Blazor WebAssembly: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```html ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see . To customize more than just the URLs for boot resources, the `loadBootResource` function can call `fetch` directly and return the result. The following example adds a custom HTTP header to the outbound requests. To retain the default integrity checking behavior, pass through the `integrity` parameter. -:::moniker range=">= aspnetcore-8.0" +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Standalone Blazor WebAssembly: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```html ``` +:::moniker-end + **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see . When the `loadBootResource` function returns `null`, Blazor uses the default loading behavior for the resource. For example, the preceding code returns `null` for the `dotnetjs` boot resource (`dotnet.*.js`) because the `dotnetjs` boot resource must either return `null` for default loading behavior or a URI for the source of the `dotnetjs` boot resource. @@ -786,8 +822,16 @@ For the placeholders in the following examples that set an environment variable: * The `{NAME}` placeholder is the environment variable's name. * The `{VALUE}` placeholder is the environment variable's value. +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Blazor Web App: +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + ```html ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Standalone Blazor WebAssembly: ```html @@ -814,6 +862,10 @@ Standalone Blazor WebAssembly: ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0" + > [!NOTE] > The .NET runtime instance can be accessed using the .NET WebAssembly Runtime API (`Blazor.runtime`). For example, the app's build configuration can be obtained using `Blazor.runtime.runtimeBuildInfo.buildConfiguration`. > diff --git a/aspnetcore/blazor/globalization-localization.md b/aspnetcore/blazor/globalization-localization.md index e864b4898f8a..33a5811099bb 100644 --- a/aspnetcore/blazor/globalization-localization.md +++ b/aspnetcore/blazor/globalization-localization.md @@ -320,10 +320,14 @@ Prevent Blazor autostart by adding `autostart="false"` to [Blazor's ` ``` +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" + Standalone Blazor WebAssembly: :::moniker-end +:::moniker range="< aspnetcore-10.0" + ```html ``` +:::moniker-end + The value for `applicationCulture` must conform to the [BCP-47 language tag format](https://www.rfc-editor.org/info/bcp47). For more information on Blazor startup, see . An alternative to setting the culture Blazor's start option is to set the culture in C# code. Set and in the `Program` file to the same culture. From 677c07483cb667069a7ed1729db5d1e81bedf39c Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Thu, 6 Feb 2025 10:21:45 -0500 Subject: [PATCH 2/5] Updates --- aspnetcore/blazor/fundamentals/signalr.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index 969debef91de..52d26f7a0584 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -893,7 +893,7 @@ Blazor Web App: :::moniker-end -:::moniker range=">= aspnetcore-8.0 +:::moniker range=">= aspnetcore-8.0" ```html @@ -933,7 +933,7 @@ Blazor Server: :::moniker-end -:::moniker range=">= aspnetcore-8.0 +:::moniker range=">= aspnetcore-8.0" **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script and the path to use, see . From 653418bbd8a61612248444cf34d400df9db03769 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Tue, 1 Apr 2025 09:32:11 -0400 Subject: [PATCH 3/5] Reconstitute WASM hosting > Compression updates --- .../host-and-deploy/webassembly/index.md | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/aspnetcore/blazor/host-and-deploy/webassembly/index.md b/aspnetcore/blazor/host-and-deploy/webassembly/index.md index b9d8195115d3..c6aad540508b 100644 --- a/aspnetcore/blazor/host-and-deploy/webassembly/index.md +++ b/aspnetcore/blazor/host-and-deploy/webassembly/index.md @@ -118,11 +118,15 @@ In the `wwwroot/index.html` file, set `autostart` to `false` on Blazor's `` tag and before the closing `` tag, add the following JavaScript code ` -``` + + +:::moniker-end + +:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" Standalone Blazor WebAssembly: :::moniker-end -```html +:::moniker range="< aspnetcore-10.0" + +html -``` + + +:::moniker-end For more information on loading boot resources, see . From dd0548ffd3079a138dc473aa28ef476318baa5a1 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Tue, 1 Apr 2025 09:53:18 -0400 Subject: [PATCH 4/5] Updates --- aspnetcore/blazor/host-and-deploy/webassembly/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aspnetcore/blazor/host-and-deploy/webassembly/index.md b/aspnetcore/blazor/host-and-deploy/webassembly/index.md index c6aad540508b..548261afed40 100644 --- a/aspnetcore/blazor/host-and-deploy/webassembly/index.md +++ b/aspnetcore/blazor/host-and-deploy/webassembly/index.md @@ -126,7 +126,7 @@ Blazor Web App: :::moniker range=">= aspnetcore-8.0" -html +```html - +``` :::moniker-end @@ -163,7 +163,7 @@ Standalone Blazor WebAssembly: :::moniker range="< aspnetcore-10.0" -html +```html - +``` :::moniker-end From ef5a6af521e2b357426c79fbe3e5823bc5c3eb4c Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Wed, 9 Jul 2025 17:26:52 -0400 Subject: [PATCH 5/5] Updates --- aspnetcore/blazor/fundamentals/signalr.md | 50 ----------------------- 1 file changed, 50 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index 5798233585aa..e378d69faeeb 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -1541,56 +1541,6 @@ protected override async Task OnInitializedAsync() :::moniker-end -## Modify the server-side reconnection handler - -The reconnection handler's circuit connection events can be modified for custom behaviors, such as: - -* To notify the user if the connection is dropped. -* To perform logging (from the client) when a circuit is connected. - -To modify the connection events, register callbacks for the following connection changes: - -* Dropped connections use `onConnectionDown`. -* Established/re-established connections use `onConnectionUp`. - -**Both `onConnectionDown` and `onConnectionUp` must be specified.** - -:::moniker range=">= aspnetcore-8.0" - -Blazor Web App: - -```html - - -``` - -Blazor Server: - -:::moniker-end - -```html - - -``` - -**In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script and the path to use, see . - :::moniker range=">= aspnetcore-7.0" ## Programmatic control of reconnection and reload behavior