From 5fb2646ada2fbe703afaa0a0586ab1625c9a69ae Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Tue, 24 Oct 2023 05:50:16 -0400 Subject: [PATCH 01/14] Manual Blazor start updates 8.0 --- aspnetcore/blazor/fundamentals/startup.md | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/aspnetcore/blazor/fundamentals/startup.md b/aspnetcore/blazor/fundamentals/startup.md index 0b716762ba41..54adbe35a2ac 100644 --- a/aspnetcore/blazor/fundamentals/startup.md +++ b/aspnetcore/blazor/fundamentals/startup.md @@ -44,6 +44,37 @@ The Blazor startup process is automatic and asynchronous via the Blazor script ( To manually start Blazor: +:::moniker range=">= aspnetcore-8.0" + +* Add an `autostart="false"` attribute and value to the Blazor ` + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.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. :::moniker range=">= aspnetcore-6.0" From 6213dcd8064414a31a84dedc1764fc65ca4fa732 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Tue, 24 Oct 2023 06:00:07 -0400 Subject: [PATCH 02/14] Updates --- aspnetcore/tutorials/signalr-typescript-webpack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/signalr-typescript-webpack.md b/aspnetcore/tutorials/signalr-typescript-webpack.md index 744bbc609e59..c599b49e5048 100644 --- a/aspnetcore/tutorials/signalr-typescript-webpack.md +++ b/aspnetcore/tutorials/signalr-typescript-webpack.md @@ -11,7 +11,7 @@ uid: tutorials/signalr-typescript-webpack --- # Tutorial: Get started with ASP.NET Core SignalR using TypeScript and Webpack -By [Sébastien Sougnez](https://twitter.com/ssougnez) +By [Sébastien Sougnez](https://be.linkedin.com/in/cvsso) [!INCLUDE[](~/includes/not-latest-version.md)] From 204fc7c68d06db72a3619c69f395898c08e79894 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Tue, 24 Oct 2023 06:03:08 -0400 Subject: [PATCH 03/14] Updates --- aspnetcore/tutorials/signalr-typescript-webpack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/signalr-typescript-webpack.md b/aspnetcore/tutorials/signalr-typescript-webpack.md index c599b49e5048..db93ad769208 100644 --- a/aspnetcore/tutorials/signalr-typescript-webpack.md +++ b/aspnetcore/tutorials/signalr-typescript-webpack.md @@ -11,7 +11,7 @@ uid: tutorials/signalr-typescript-webpack --- # Tutorial: Get started with ASP.NET Core SignalR using TypeScript and Webpack -By [Sébastien Sougnez](https://be.linkedin.com/in/cvsso) +By [Sébastien Sougnez](https://twitter.com/s_sougnez) [!INCLUDE[](~/includes/not-latest-version.md)] From 5ba6d0c99f598373b4c3213f8779b526d51b570e Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Tue, 24 Oct 2023 06:45:15 -0400 Subject: [PATCH 04/14] Updates --- .../blazor/fundamentals/environments.md | 23 ++++ aspnetcore/blazor/fundamentals/logging.md | 41 ++++++ aspnetcore/blazor/fundamentals/signalr.md | 126 +++++++++++++++++- aspnetcore/blazor/fundamentals/startup.md | 62 ++++++++- .../blazor/globalization-localization.md | 18 +++ aspnetcore/blazor/host-and-deploy/server.md | 6 +- .../blazor/host-and-deploy/webassembly.md | 1 - aspnetcore/release-notes/aspnetcore-8.0.md | 6 +- 8 files changed, 272 insertions(+), 11 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index 11c6dc2301b6..62f4f08d75b9 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -71,6 +71,27 @@ For more information on how to configure the server-side environment, see + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```html ``` +:::moniker-end + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. Using the `environment` property overrides the environment set by the [`Blazor-Environment` header](#set-the-environment-via-header). diff --git a/aspnetcore/blazor/fundamentals/logging.md b/aspnetcore/blazor/fundamentals/logging.md index ad1d9af18efd..e01a35d45f20 100644 --- a/aspnetcore/blazor/fundamentals/logging.md +++ b/aspnetcore/blazor/fundamentals/logging.md @@ -678,6 +678,25 @@ 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" + +```html + + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```html ``` +:::moniker-end + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. Example 2: Set the log level with an integer value: +:::moniker range=">= aspnetcore-8.0" + +```html + + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```html ``` +:::moniker-end + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. For more information on Blazor startup (`Blazor.start()`), see . diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index 98cbb688446e..bdd365225a6a 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -670,8 +670,10 @@ The following example for the `App.razor` file (Blazor Web App) shows the assign @@ -772,6 +774,26 @@ To modify the connection events, register callbacks for the following connection **Both `onConnectionDown` and `onConnectionUp` must be specified.** +:::moniker range=">= aspnetcore-8.0" + +```html + + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```html ``` +:::moniker-end + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. :::moniker range=">= aspnetcore-7.0" @@ -818,6 +842,76 @@ In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script `wwwroot/boot.js`: +:::moniker range=">= aspnetcore-8.0" + +```javascript +(() => { + const maximumRetryCount = 3; + const retryIntervalMilliseconds = 5000; + const reconnectModal = document.getElementById('reconnect-modal'); + + const startReconnectionProcess = () => { + reconnectModal.style.display = 'block'; + + let isCanceled = false; + + (async () => { + for (let i = 0; i < maximumRetryCount; i++) { + reconnectModal.innerText = `Attempting to reconnect: ${i + 1} of ${maximumRetryCount}`; + + await new Promise(resolve => setTimeout(resolve, retryIntervalMilliseconds)); + + if (isCanceled) { + return; + } + + try { + const result = await Blazor.reconnect(); + if (!result) { + // The server was reached, but the connection was rejected; reload the page. + location.reload(); + return; + } + + // Successfully reconnected to the server. + return; + } catch { + // Didn't reach the server; try again. + } + } + + // Retried too many times; reload the page. + location.reload(); + })(); + + return { + cancel: () => { + isCanceled = true; + reconnectModal.style.display = 'none'; + }, + }; + }; + + let currentReconnectionProcess = null; + + Blazor.start({ + circuit: { + reconnectionHandler: { + onConnectionDown: () => currentReconnectionProcess ??= startReconnectionProcess(), + onConnectionUp: () => { + currentReconnectionProcess?.cancel(); + currentReconnectionProcess = null; + } + } + } + }); +})(); +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```javascript (() => { const maximumRetryCount = 3; @@ -874,12 +968,14 @@ In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script onConnectionUp: () => { currentReconnectionProcess?.cancel(); currentReconnectionProcess = null; - }, - }, + } + } }); })(); ``` +:::moniker-end + For more information on Blazor startup, see . :::moniker-end @@ -888,6 +984,26 @@ 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" + +```html + + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```html ``` +:::moniker-end + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. For more information on Blazor startup, see . diff --git a/aspnetcore/blazor/fundamentals/startup.md b/aspnetcore/blazor/fundamentals/startup.md index 54adbe35a2ac..7d3284565ef1 100644 --- a/aspnetcore/blazor/fundamentals/startup.md +++ b/aspnetcore/blazor/fundamentals/startup.md @@ -293,6 +293,31 @@ 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" + +```html + + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```html ``` +:::moniker-end + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. 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" + +```html + + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.0" + ```html ``` +:::moniker-end + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. 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. @@ -503,8 +559,10 @@ The following example sets an environment variable, `CONFIGURE_RUNTIME`, to `tru diff --git a/aspnetcore/blazor/globalization-localization.md b/aspnetcore/blazor/globalization-localization.md index 62dc1516a31b..95450c3a056f 100644 --- a/aspnetcore/blazor/globalization-localization.md +++ b/aspnetcore/blazor/globalization-localization.md @@ -271,6 +271,22 @@ The app's culture can be set in JavaScript when Blazor starts with the `applicat * Add the following ` + ``` + +:::moniker-end + +:::moniker range="< aspnetcore-8.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. diff --git a/aspnetcore/blazor/host-and-deploy/server.md b/aspnetcore/blazor/host-and-deploy/server.md index 5cb89cd10381..9f164b9e8ea5 100644 --- a/aspnetcore/blazor/host-and-deploy/server.md +++ b/aspnetcore/blazor/host-and-deploy/server.md @@ -133,8 +133,10 @@ If a deployed app frequently displays the reconnection UI due to ping timeouts c ```html diff --git a/aspnetcore/blazor/host-and-deploy/webassembly.md b/aspnetcore/blazor/host-and-deploy/webassembly.md index de4d2c976bca..063828e01a85 100644 --- a/aspnetcore/blazor/host-and-deploy/webassembly.md +++ b/aspnetcore/blazor/host-and-deploy/webassembly.md @@ -211,7 +211,6 @@ Blazor relies on the host to serve the appropriate compressed files. When using For more information on loading boot resources, see . - :::moniker range=">= aspnetcore-8.0" To disable compression, add the `CompressionEnabled` MSBuild property to the app's project file and set the value to `false`: diff --git a/aspnetcore/release-notes/aspnetcore-8.0.md b/aspnetcore/release-notes/aspnetcore-8.0.md index 35294a6ec4fb..6fad767edd17 100644 --- a/aspnetcore/release-notes/aspnetcore-8.0.md +++ b/aspnetcore/release-notes/aspnetcore-8.0.md @@ -338,8 +338,10 @@ The following example shows the ***new approach*** for assigning values that are ```javascript Blazor.start({ - configureSignalR: function (builder) { - builder.withServerTimeout(60000).withKeepAliveInterval(30000); + circuit: { + configureSignalR: function (builder) { + builder.withServerTimeout(60000).withKeepAliveInterval(30000); + } } }); ``` From 942885399b1c48f62f76951573dfb1c184b82e89 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Tue, 24 Oct 2023 07:03:48 -0400 Subject: [PATCH 05/14] Updates --- aspnetcore/blazor/fundamentals/signalr.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index bdd365225a6a..50f690c78e43 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -842,6 +842,8 @@ In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script `wwwroot/boot.js`: +:::moniker-end + :::moniker range=">= aspnetcore-8.0" ```javascript @@ -910,7 +912,7 @@ In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script :::moniker-end -:::moniker range="< aspnetcore-8.0" +:::moniker range=">= aspnetcore-7.0 < aspnetcore-8.0" ```javascript (() => { @@ -976,6 +978,8 @@ In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script :::moniker-end +:::moniker range=">= aspnetcore-7.0" + For more information on Blazor startup, see . :::moniker-end From 4dd979f6c1f610b0f9c3680598d5e784eecd532e Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:14:06 -0400 Subject: [PATCH 06/14] Apply suggestions from code review Co-authored-by: Mackinnon Buck --- aspnetcore/blazor/fundamentals/logging.md | 1 + aspnetcore/blazor/fundamentals/startup.md | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/logging.md b/aspnetcore/blazor/fundamentals/logging.md index e01a35d45f20..303d2e3458bd 100644 --- a/aspnetcore/blazor/fundamentals/logging.md +++ b/aspnetcore/blazor/fundamentals/logging.md @@ -723,6 +723,7 @@ Example 2: Set the log circuit: { configureSignalR: function (builder) { builder.configureLogging(2); + } } }); diff --git a/aspnetcore/blazor/fundamentals/startup.md b/aspnetcore/blazor/fundamentals/startup.md index 7d3284565ef1..8baa1a88786e 100644 --- a/aspnetcore/blazor/fundamentals/startup.md +++ b/aspnetcore/blazor/fundamentals/startup.md @@ -48,9 +48,9 @@ To manually start Blazor: * Add an `autostart="false"` attribute and value to the Blazor ` From df03b0d015509e99d087e48d156517d635b47cab Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:32:26 -0400 Subject: [PATCH 07/14] Update aspnetcore/blazor/fundamentals/logging.md Co-authored-by: Brennan --- aspnetcore/blazor/fundamentals/logging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/fundamentals/logging.md b/aspnetcore/blazor/fundamentals/logging.md index 303d2e3458bd..d528dbe3c415 100644 --- a/aspnetcore/blazor/fundamentals/logging.md +++ b/aspnetcore/blazor/fundamentals/logging.md @@ -722,7 +722,7 @@ Example 2: Set the log Blazor.start({ circuit: { configureSignalR: function (builder) { - builder.configureLogging(2); + builder.configureLogging("information"); } } }); From e6cfe21d8e87322814a6fc6b29f03077784c3af0 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Wed, 25 Oct 2023 08:16:04 -0400 Subject: [PATCH 08/14] Updates --- .../blazor/fundamentals/environments.md | 8 +- aspnetcore/blazor/fundamentals/logging.md | 24 ++-- aspnetcore/blazor/fundamentals/signalr.md | 36 +++++- aspnetcore/blazor/fundamentals/startup.md | 41 ++++--- .../blazor/globalization-localization.md | 12 ++ aspnetcore/blazor/host-and-deploy/server.md | 18 ++- .../blazor/host-and-deploy/webassembly.md | 103 ++++++++++++------ aspnetcore/release-notes/aspnetcore-8.0.md | 16 ++- 8 files changed, 185 insertions(+), 73 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index 62f4f08d75b9..57676914bb81 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -73,6 +73,8 @@ The following example starts Blazor in the `Staging` environment if the hostname :::moniker range=">= aspnetcore-8.0" +Blazor Web App: + ```html ``` -:::moniker-end +Standalone Blazor WebAssembly: -:::moniker range="< aspnetcore-8.0" +:::moniker-end ```html @@ -105,8 +107,6 @@ The following example starts Blazor in the `Staging` environment if the hostname ``` -:::moniker-end - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. Using the `environment` property overrides the environment set by the [`Blazor-Environment` header](#set-the-environment-via-header). diff --git a/aspnetcore/blazor/fundamentals/logging.md b/aspnetcore/blazor/fundamentals/logging.md index d528dbe3c415..30e5b287b722 100644 --- a/aspnetcore/blazor/fundamentals/logging.md +++ b/aspnetcore/blazor/fundamentals/logging.md @@ -676,10 +676,12 @@ For the `configureLogging` log level value, pass the argument as either the stri | | `critical` | 5 | | | `none` | 6 | -Example 1: Set the log level with a string value: +Example 1: Set the log level with a string value. :::moniker range=">= aspnetcore-8.0" +Blazor Web App: + ```html ``` -:::moniker-end +Blazor Server: -:::moniker range="< aspnetcore-8.0" +:::moniker-end ```html @@ -708,16 +710,16 @@ Example 1: Set the log ``` -:::moniker-end - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. -Example 2: Set the log level with an integer value: +Example 2: Set the log level with an integer value. :::moniker range=">= aspnetcore-8.0" +Blazor Web App: + ```html - + ``` -:::moniker-end +Blazor Server: -:::moniker range="< aspnetcore-8.0" +:::moniker-end ```html - + ``` -:::moniker-end - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. For more information on Blazor startup (`Blazor.start()`), see . diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index 50f690c78e43..739dbe98a75e 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -664,7 +664,9 @@ Configure the following values for the client: * `withServerTimeout`: Configures the server timeout in milliseconds. If this timeout elapses without receiving any messages from the server, the connection is terminated with an error. The default timeout value is 30 seconds. The server timeout should be at least double the value assigned to the Keep-Alive interval (`withKeepAliveInterval`). * `withKeepAliveInterval`: Configures the Keep-Alive interval in milliseconds (default interval at which to ping the server). This setting allows the server to detect hard disconnects, such as when a client unplugs their computer from the network. The ping occurs at most as often as the server pings. If the server pings every five seconds, assigning a value lower than `5000` (5 seconds) pings every five seconds. The default value is 15 seconds. The Keep-Alive interval should be less than or equal to half the value assigned to the server timeout (`withServerTimeout`). -The following example for the `App.razor` file (Blazor Web App) shows the assignment of default values: +The following example for the `App.razor` file (Blazor Web App) shows the assignment of default values. + +Blazor Web App: ```html @@ -679,6 +681,20 @@ The following example for the `App.razor` file (Blazor Web App) shows the assign ``` +Blazor Server: The following example for the `Pages/_Host.cshtml` file (Blazor Server, all versions except ASP.NET Core 6.0) or `Pages/_Layout.cshtml` file (Blazor Server, ASP.NET Core 6.0). + +Blazor Server: + +```html + + +``` + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. 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: @@ -776,6 +792,8 @@ To modify the connection events, register callbacks for the following connection :::moniker range=">= aspnetcore-8.0" +Blazor Web App: + ```html ``` -:::moniker-end +Blazor Server: -:::moniker range="< aspnetcore-8.0" +:::moniker-end * 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. :::moniker range=">= aspnetcore-6.0" @@ -295,6 +295,8 @@ The `{TARGET FRAMEWORK}` placeholder is the target framework moniker (for exampl :::moniker range=">= aspnetcore-8.0" +Blazor Web App: + ```html ``` -:::moniker-end +Standalone Blazor WebAssembly: -:::moniker range="< aspnetcore-8.0" +:::moniker-end ```html @@ -335,14 +337,14 @@ The `{TARGET FRAMEWORK}` placeholder is the target framework moniker (for exampl ``` -:::moniker-end - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. 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" +Blazor Web App: + ```html ``` -:::moniker-end +Standalone Blazor WebAssembly: -:::moniker range="< aspnetcore-8.0" +:::moniker-end ```html @@ -387,8 +389,6 @@ To customize more than just the URLs for boot resources, the `loadBootResource` ``` -:::moniker-end - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. 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. @@ -555,6 +555,8 @@ To configure the .NET WebAssembly runtime, use the `configureRuntime` function w The following example sets an environment variable, `CONFIGURE_RUNTIME`, to `true`: +Blazor Web App: + ```html ``` +Standalone Blazor WebAssembly: + +```html + + +``` + In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. The .NET runtime instance can be accessed from `Blazor.runtime`. @@ -580,7 +595,7 @@ The .NET runtime instance can be accessed from `Blazor.runtime`. *This section applies to Blazor Web Apps.* -To disable enhanced navigation and form handling, set `disableDomPreservation` to `true` for `Blazor.start`: +To disable enhanced navigation and form handling, set `disableDomPreservation` to `true` for `Blazor.start`. ```html diff --git a/aspnetcore/blazor/globalization-localization.md b/aspnetcore/blazor/globalization-localization.md index 95450c3a056f..8b3757646336 100644 --- a/aspnetcore/blazor/globalization-localization.md +++ b/aspnetcore/blazor/globalization-localization.md @@ -273,6 +273,8 @@ The app's culture can be set in JavaScript when Blazor starts with the `applicat :::moniker range=">= aspnetcore-8.0" + Blazor Web App: + ```html ``` + Standalone Blazor WebAssembly: + + ```html + + ``` + :::moniker-end :::moniker range="< aspnetcore-8.0" diff --git a/aspnetcore/blazor/host-and-deploy/server.md b/aspnetcore/blazor/host-and-deploy/server.md index 9f164b9e8ea5..507b2bd4a3c2 100644 --- a/aspnetcore/blazor/host-and-deploy/server.md +++ b/aspnetcore/blazor/host-and-deploy/server.md @@ -128,7 +128,9 @@ If a deployed app frequently displays the reconnection UI due to ping timeouts c > > In the following example, a custom value of 60 seconds is used for the server timeout. - In the [startup configuration](xref:blazor/fundamentals/startup) of a server-side Blazor app after the Blazor script (`blazor.*.js`) ` ``` + Blazor Server: + + ```html + + ``` + When creating a hub connection in a component, set the (default: 30 seconds) on the . Set the (default: 15 seconds) on the built . 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: @@ -173,7 +187,7 @@ If a deployed app frequently displays the reconnection UI due to ping timeouts c > > In the following example, a custom value of 60 seconds is used for the server timeout. - In `Pages/_Host.cshtml`: + The following example applies to `Pages/_Host.cshtml`: ```html diff --git a/aspnetcore/blazor/host-and-deploy/webassembly.md b/aspnetcore/blazor/host-and-deploy/webassembly.md index 063828e01a85..c3b07d8c1538 100644 --- a/aspnetcore/blazor/host-and-deploy/webassembly.md +++ b/aspnetcore/blazor/host-and-deploy/webassembly.md @@ -169,47 +169,82 @@ Blazor relies on the host to serve the appropriate compressed files. When using * For IIS `web.config` compression configuration, see the [IIS: Brotli and Gzip compression](#brotli-and-gzip-compression) section. * When hosting on static hosting solutions that don't support statically-compressed file content negotiation, consider configuring the app to fetch and decode Brotli compressed files: - * Obtain the JavaScript Brotli decoder from the [google/brotli GitHub repository](https://github.com/google/brotli). The minified decoder file is named `decode.min.js` and found in the repository's [`js` folder](https://github.com/google/brotli/tree/master/js). +Obtain the JavaScript Brotli decoder from the [google/brotli GitHub repository](https://github.com/google/brotli). The minified decoder file is named `decode.min.js` and found in the repository's [`js` folder](https://github.com/google/brotli/tree/master/js). - > [!NOTE] - > If the minified version of the `decode.js` script (`decode.min.js`) fails, try using the unminified version (`decode.js`) instead. +> [!NOTE] +> If the minified version of the `decode.js` script (`decode.min.js`) fails, try using the unminified version (`decode.js`) instead. - * Update the app to use the decoder. +Update the app to use the decoder. - In the `wwwroot/index.html` file, set `autostart` to `false` on Blazor's ` - ``` +```html + +``` - After Blazor's ` - ``` + } + } + }); + +``` + +Standalone Blazor WebAssembly: + +:::moniker-end + +```html + +``` - For more information on loading boot resources, see . +For more information on loading boot resources, see . :::moniker range=">= aspnetcore-8.0" diff --git a/aspnetcore/release-notes/aspnetcore-8.0.md b/aspnetcore/release-notes/aspnetcore-8.0.md index 6fad767edd17..b3c504e7013a 100644 --- a/aspnetcore/release-notes/aspnetcore-8.0.md +++ b/aspnetcore/release-notes/aspnetcore-8.0.md @@ -332,9 +332,11 @@ Blazor.start({ }); ``` -#### New approach for the JavaScript client of a Blazor Server app +#### New approach for the JavaScript client of server-side Blazor app -The following example shows the ***new approach*** for assigning values that are double the default values in ASP.NET Core 8.0 or later: +The following example shows the ***new approach*** for assigning values that are double the default values in ASP.NET Core 8.0 or later for Blazor Web Apps and Blazor Server. + +Blazor Web App: ```javascript Blazor.start({ @@ -346,6 +348,16 @@ Blazor.start({ }); ``` +Blazor Server: + +```javascript +Blazor.start({ + configureSignalR: function (builder) { + builder.withServerTimeout(60000).withKeepAliveInterval(30000); + } +}); +``` + #### Prior approach for .NET clients The following example shows the assignment of values that are double the default values in ASP.NET Core 7.0 or earlier: From ba5c9b6c5ec6d3c0e8a08d9f4a58cad1025adaba Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Wed, 25 Oct 2023 08:19:41 -0400 Subject: [PATCH 09/14] Updates --- aspnetcore/blazor/host-and-deploy/server.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/host-and-deploy/server.md b/aspnetcore/blazor/host-and-deploy/server.md index 507b2bd4a3c2..3dd4632dd13a 100644 --- a/aspnetcore/blazor/host-and-deploy/server.md +++ b/aspnetcore/blazor/host-and-deploy/server.md @@ -146,7 +146,7 @@ If a deployed app frequently displays the reconnection UI due to ping timeouts c Blazor Server: - ```html + ```html ``` -Blazor Server: The following example for the `Pages/_Host.cshtml` file (Blazor Server, all versions except ASP.NET Core 6.0) or `Pages/_Layout.cshtml` file (Blazor Server, ASP.NET Core 6.0). +The following example for the `Pages/_Host.cshtml` file (Blazor Server, all versions except ASP.NET Core 6.0) or `Pages/_Layout.cshtml` file (Blazor Server, ASP.NET Core 6.0). Blazor Server: @@ -808,12 +808,10 @@ Blazor Web App: ``` -:::moniker-end - -:::moniker range="< aspnetcore-8.0" - Blazor Server: +:::moniker-end + ```html ``` -:::moniker-end - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. :::moniker range=">= aspnetcore-7.0" @@ -936,6 +932,8 @@ Blazor Server: :::moniker-end +:::moniker range=">= aspnetcore-7.0" + ```javascript (() => { const maximumRetryCount = 3; @@ -998,8 +996,6 @@ Blazor Server: })(); ``` -:::moniker range=">= aspnetcore-7.0" - For more information on Blazor startup, see . :::moniker-end diff --git a/aspnetcore/blazor/globalization-localization.md b/aspnetcore/blazor/globalization-localization.md index 8b3757646336..2399012304dd 100644 --- a/aspnetcore/blazor/globalization-localization.md +++ b/aspnetcore/blazor/globalization-localization.md @@ -261,54 +261,42 @@ By default, the Intermediate Language (IL) Linker configuration for client-side The app's culture can be set in JavaScript when Blazor starts with the `applicationCulture` Blazor start option. The following example configures the app to launch using the United States English (`en-US`) culture. -* Prevent Blazor autostart by adding `autostart="false"` to Blazor's script tag: +Prevent Blazor autostart by adding `autostart="false"` to Blazor's script tag: - ```html - - ``` +```html + +``` - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. +In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. -* Add the following ` - ``` - - Standalone Blazor WebAssembly: +Blazor Web App: - ```html - - ``` - -:::moniker-end - -:::moniker range="< aspnetcore-8.0" + } + }); + +``` - ```html - - ``` +Standalone Blazor WebAssembly: :::moniker-end +```html + +``` + 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. diff --git a/aspnetcore/blazor/host-and-deploy/server.md b/aspnetcore/blazor/host-and-deploy/server.md index 3dd4632dd13a..2492e792b17f 100644 --- a/aspnetcore/blazor/host-and-deploy/server.md +++ b/aspnetcore/blazor/host-and-deploy/server.md @@ -187,7 +187,7 @@ If a deployed app frequently displays the reconnection UI due to ping timeouts c > > In the following example, a custom value of 60 seconds is used for the server timeout. - The following example applies to `Pages/_Host.cshtml`: + In `Pages/_Host.cshtml`: ```html From 9843977c777afb56c77b9369aea221faa5deae91 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Wed, 25 Oct 2023 08:45:20 -0400 Subject: [PATCH 11/14] Updates --- aspnetcore/blazor/fundamentals/signalr.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index 47e9e756cad8..e043daffe571 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -1022,12 +1022,10 @@ Blazor Web App: ``` -:::moniker-end - -:::moniker range="< aspnetcore-8.0" - Blazor Server: +:::moniker-end + ```html ``` -:::moniker-end - In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name. For more information on Blazor startup, see . From 14db0a8813d537271d0e9c7729470ccf6b5500e7 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:21:36 -0400 Subject: [PATCH 12/14] Updates --- aspnetcore/blazor/fundamentals/startup.md | 23 ++++------ aspnetcore/blazor/project-structure.md | 56 +++++++++++++++++++++++ 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/startup.md b/aspnetcore/blazor/fundamentals/startup.md index 228b04712107..ff0fd2a7677a 100644 --- a/aspnetcore/blazor/fundamentals/startup.md +++ b/aspnetcore/blazor/fundamentals/startup.md @@ -20,28 +20,25 @@ For general guidance on ASP.NET Core app configuration for server-side developme :::moniker range=">= aspnetcore-8.0" -The Blazor startup process is automatic and asynchronous via the Blazor script (`blazor.*.js`), where `*` is either `web` for a Blazor Web App or `webassembly` for a Blazor WebAssembly app. The Blazor ` +``` + +In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml` file: + +``` + +``` + +:::moniker-end + +:::moniker range=">= aspnetcore-7.0 < aspnetcore-8.0" + +In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml` file: + +``` + +``` + +:::moniker-end + +:::moniker range=">= aspnetcore-6.0 < aspnetcore-7.0" + +In a Blazor Server app, the Blazor script is located in the `Pages/_Layout.cshtml` file: + +``` + +``` + +:::moniker-end + +:::moniker range="< aspnetcore-6.0" + +In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml` file: + +``` + +``` + +:::moniker-end + +In a Blazor WebAssembly app, the Blazor script content is located in the `wwwroot/index.html` file: + +``` + +``` + ## Location of `` and `` content :::moniker range=">= aspnetcore-8.0" From 834bdd7f171f4c574c99f28205d214a64a9ac47e Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:09:16 -0400 Subject: [PATCH 13/14] Updates --- aspnetcore/migration/70-80.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/aspnetcore/migration/70-80.md b/aspnetcore/migration/70-80.md index bc2fc70de7a4..1ec26b75500d 100644 --- a/aspnetcore/migration/70-80.md +++ b/aspnetcore/migration/70-80.md @@ -77,14 +77,29 @@ In the project file, update each [`Microsoft.AspNetCore.*`](https://www.nuget.or The following migration scenarios are covered: -* [Adopt Blazor Web App conventions](#adopt-blazor-web-app-conventions) +* [Update a Blazor Server app](#update-a-blazor-server-app) +* [Adopt all Blazor Web App conventions](#adopt-all-blazor-web-app-conventions) * [Convert a Blazor Server app into a Blazor Web App](#convert-a-blazor-server-app-into-a-blazor-web-app) +* [Update a Blazor WebAssembly app](#update-a-blazor-webassembly-app) * [Convert a hosted Blazor WebAssembly app into a Blazor Web App](#convert-a-hosted-blazor-webassembly-app-into-a-blazor-web-app) * [Update service and endpoint option configuration](#update-service-and-endpoint-option-configuration) For guidance on adding Blazor support to an ASP.NET Core app, see . -### Adopt Blazor Web App conventions +### Update a Blazor Server app + +We recommend using Blazor Web Apps in .NET 8, but Blazor Server is supported. To continue using Blazor Server with .NET 8, follow the guidance in the first three sections of this article: + +* [Update the .NET SDK version in `global.json`](#update-the-net-sdk-version-in-globaljson) +* [Update the target framework](#update-the-target-framework) +* [Update package references](#update-package-references) + +New Blazor features introduced for Blazor Web Apps aren't available to a Blazor Server app updated to run under .NET 8. If you wish to adopt the new .NET 8 Blazor features, follow the guidance in either of the following sections: + +* [Adopt all Blazor Web App conventions](#adopt-all-blazor-web-app-conventions) +* [Convert a Blazor Server app into a Blazor Web App](#convert-a-blazor-server-app-into-a-blazor-web-app) + +### Adopt all Blazor Web App conventions To optionally adopt all of the new Blazor Web App conventions, we recommend the following process: @@ -274,6 +289,14 @@ Blazor Server apps are supported in .NET 8 without any code changes. Use the fol For more information, see . +### Update a Blazor WebAssembly app + +Follow the guidance in the first three sections of this article: + +* [Update the .NET SDK version in `global.json`](#update-the-net-sdk-version-in-globaljson) +* [Update the target framework](#update-the-target-framework) +* [Update package references](#update-package-references) + ### Convert a hosted Blazor WebAssembly app into a Blazor Web App Blazor WebAssembly apps are supported in .NET 8 without any code changes. Use the following guidance to convert an ASP.NET Core hosted Blazor WebAssembly app into an equivalent .NET 8 Blazor Web App, which makes all of the [new .NET 8 features](xref:aspnetcore-8#blazor) available. From 8f276487f810668cdc21283d4bde7b375ecd20bb Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:13:50 -0400 Subject: [PATCH 14/14] Updates --- aspnetcore/migration/70-80.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnetcore/migration/70-80.md b/aspnetcore/migration/70-80.md index 1ec26b75500d..788404aa08e1 100644 --- a/aspnetcore/migration/70-80.md +++ b/aspnetcore/migration/70-80.md @@ -114,7 +114,7 @@ New .NET 8 features are covered in . When updating an Blazor Server apps are supported in .NET 8 without any code changes. Use the following guidance to convert a Blazor Server app into an equivalent .NET 8 Blazor Web App, which makes all of the [new .NET 8 features](xref:aspnetcore-8#blazor) available. > [!IMPORTANT] -> This section focuses on the minimal changes required to convert a .NET 7 Blazor Server app into a .NET 8 Blazor Web App. To adopt all of the new Blazor Web App conventions, follow the guidance in the [Adopt Blazor Web App conventions](#adopt-blazor-web-app-conventions) section. +> This section focuses on the minimal changes required to convert a .NET 7 Blazor Server app into a .NET 8 Blazor Web App. To adopt all of the new Blazor Web App conventions, follow the guidance in the [Adopt all Blazor Web App conventions](#adopt-all-blazor-web-app-conventions) section. 1. Follow the guidance in the first three sections of this article: @@ -302,7 +302,7 @@ Follow the guidance in the first three sections of this article: Blazor WebAssembly apps are supported in .NET 8 without any code changes. Use the following guidance to convert an ASP.NET Core hosted Blazor WebAssembly app into an equivalent .NET 8 Blazor Web App, which makes all of the [new .NET 8 features](xref:aspnetcore-8#blazor) available. > [!IMPORTANT] -> This section focuses on the minimal changes required to convert a .NET 7 ASP.NET Core hosted Blazor WebAssembly app into a .NET 8 Blazor Web App. To adopt all of the new Blazor Web App conventions, follow the guidance in the [Adopt Blazor Web App conventions](#adopt-blazor-web-app-conventions) section. +> This section focuses on the minimal changes required to convert a .NET 7 ASP.NET Core hosted Blazor WebAssembly app into a .NET 8 Blazor Web App. To adopt all of the new Blazor Web App conventions, follow the guidance in the [Adopt all Blazor Web App conventions](#adopt-all-blazor-web-app-conventions) section. 1. Follow the guidance in the first three sections of this article: