Skip to content

Commit f00289b

Browse files
committed
Blazor startup options format
1 parent 03b2c9f commit f00289b

File tree

5 files changed

+203
-17
lines changed

5 files changed

+203
-17
lines changed

aspnetcore/blazor/fundamentals/environments.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ For general guidance on ASP.NET Core app configuration, see <xref:fundamentals/e
6868

6969
The following example starts Blazor in the `Staging` environment if the hostname includes `localhost`. Otherwise, the environment is set to its default value.
7070

71-
:::moniker range=">= aspnetcore-8.0"
71+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
7272

7373
Blazor Web App:
7474

75+
:::moniker-end
76+
77+
:::moniker range=">= aspnetcore-8.0"
78+
7579
```html
7680
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
7781
<script>
@@ -92,10 +96,16 @@ Blazor Web App:
9296
> [!NOTE]
9397
> For Blazor Web Apps that set the `webAssembly` > `environment` property in `Blazor.start` configuration, it's wise to match the server-side environment to the environment set on the `environment` property. Otherwise, prerendering on the server will operate under a different environment than rendering on the client, which results in arbitrary effects. For general guidance on setting the environment for a Blazor Web App, see <xref:fundamentals/environments>.
9498
99+
:::moniker-end
100+
101+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
102+
95103
Standalone Blazor WebAssembly:
96104

97105
:::moniker-end
98106

107+
:::moniker range="< aspnetcore-10.0"
108+
99109
```html
100110
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
101111
<script>
@@ -109,6 +119,8 @@ Standalone Blazor WebAssembly:
109119
</script>
110120
```
111121

122+
:::moniker-end
123+
112124
**In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see <xref:blazor/project-structure#location-of-the-blazor-script>.
113125

114126
Using the `environment` property overrides the environment set by the [`Blazor-Environment` header](#set-the-client-side-environment-via-header).

aspnetcore/blazor/fundamentals/logging.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,14 @@ For the `configureLogging` log level value, pass the argument as either the stri
670670

671671
Example 1: Set the <xref:Microsoft.Extensions.Logging.LogLevel.Information> log level with a string value.
672672

673-
:::moniker range=">= aspnetcore-8.0"
673+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
674674

675675
Blazor Web App:
676676

677+
:::moniker-end
678+
679+
:::moniker range=">= aspnetcore-8.0"
680+
677681
```html
678682
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
679683
<script>
@@ -687,10 +691,16 @@ Blazor Web App:
687691
</script>
688692
```
689693

694+
:::moniker-end
695+
696+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
697+
690698
Blazor Server:
691699

692700
:::moniker-end
693701

702+
:::moniker range="< aspnetcore-10.0"
703+
694704
```html
695705
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
696706
<script>
@@ -702,14 +712,20 @@ Blazor Server:
702712
</script>
703713
```
704714

715+
:::moniker-end
716+
705717
**In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see <xref:blazor/project-structure#location-of-the-blazor-script>.
706718

707719
Example 2: Set the <xref:Microsoft.Extensions.Logging.LogLevel.Information> log level with an integer value.
708720

709-
:::moniker range=">= aspnetcore-8.0"
721+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
710722

711723
Blazor Web App:
712724

725+
:::moniker-end
726+
727+
:::moniker range=">= aspnetcore-8.0"
728+
713729
```html
714730
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
715731
<script>
@@ -723,10 +739,16 @@ Blazor Web App:
723739
</script>
724740
```
725741

742+
:::moniker-end
743+
744+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
745+
726746
Blazor Server:
727747

728748
:::moniker-end
729749

750+
:::moniker range="< aspnetcore-10.0"
751+
730752
```html
731753
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
732754
<script>
@@ -738,6 +760,8 @@ Blazor Server:
738760
</script>
739761
```
740762

763+
:::moniker-end
764+
741765
**In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see <xref:blazor/project-structure#location-of-the-blazor-script>.
742766

743767
> [!NOTE]

aspnetcore/blazor/fundamentals/signalr.md

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,16 @@ Configure the following values for the client:
885885

886886
The following example for the `App.razor` file (Blazor Web App) shows the assignment of default values.
887887

888+
:::moniker-end
889+
890+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
891+
888892
Blazor Web App:
889893

894+
:::moniker-end
895+
896+
:::moniker range=">= aspnetcore-8.0
897+
890898
```html
891899
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
892900
<script>
@@ -902,8 +910,16 @@ Blazor Web App:
902910

903911
The following example for the `Pages/_Host.cshtml` file (Blazor Server, all versions except ASP.NET Core in .NET 6) or `Pages/_Layout.cshtml` file (Blazor Server, ASP.NET Core in .NET 6).
904912

913+
:::moniker-end
914+
915+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
916+
905917
Blazor Server:
906918

919+
:::moniker-end
920+
921+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
922+
907923
```html
908924
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
909925
<script>
@@ -915,6 +931,10 @@ Blazor Server:
915931
</script>
916932
```
917933

934+
:::moniker-end
935+
936+
:::moniker range=">= aspnetcore-8.0
937+
918938
**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 <xref:blazor/project-structure#location-of-the-blazor-script>.
919939

920940
When creating a hub connection in a component, set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout> (default: 30 seconds) and <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.KeepAliveInterval> (default: 15 seconds) on the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder>. Set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeTimeout> (default: 15 seconds) on the built <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>. The following example shows the assignment of default values:
@@ -1010,10 +1030,14 @@ To modify the connection events, register callbacks for the following connection
10101030

10111031
**Both `onConnectionDown` and `onConnectionUp` must be specified.**
10121032

1013-
:::moniker range=">= aspnetcore-8.0"
1033+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
10141034

10151035
Blazor Web App:
10161036

1037+
:::moniker-end
1038+
1039+
:::moniker range=">= aspnetcore-8.0"
1040+
10171041
```html
10181042
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
10191043
<script>
@@ -1028,10 +1052,16 @@ Blazor Web App:
10281052
</script>
10291053
```
10301054

1055+
:::moniker-end
1056+
1057+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1058+
10311059
Blazor Server:
10321060

10331061
:::moniker-end
10341062

1063+
:::moniker range="< aspnetcore-10.0"
1064+
10351065
```html
10361066
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
10371067
<script>
@@ -1044,6 +1074,8 @@ Blazor Server:
10441074
</script>
10451075
```
10461076

1077+
:::moniker-end
1078+
10471079
**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 <xref:blazor/project-structure#location-of-the-blazor-script>.
10481080

10491081
:::moniker range=">= aspnetcore-7.0"
@@ -1080,10 +1112,14 @@ Create the following `wwwroot/boot.js` file.
10801112

10811113
:::moniker-end
10821114

1083-
:::moniker range=">= aspnetcore-8.0"
1115+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
10841116

10851117
Blazor Web App:
10861118

1119+
:::moniker-end
1120+
1121+
:::moniker range=">= aspnetcore-8.0"
1122+
10871123
```javascript
10881124
(() => {
10891125
const maximumRetryCount = 3;
@@ -1148,11 +1184,15 @@ Blazor Web App:
11481184
})();
11491185
```
11501186

1187+
:::moniker-end
1188+
1189+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1190+
11511191
Blazor Server:
11521192

11531193
:::moniker-end
11541194

1155-
:::moniker range=">= aspnetcore-7.0"
1195+
:::moniker range=">= aspnetcore-7.0 < aspnetcore-10.0"
11561196

11571197
```javascript
11581198
(() => {
@@ -1224,10 +1264,14 @@ For more information on Blazor startup, see <xref:blazor/fundamentals/startup>.
12241264

12251265
To adjust the reconnection retry count and interval, set the number of retries (`maxRetries`) and period in milliseconds permitted for each retry attempt (`retryIntervalMilliseconds`).
12261266

1227-
:::moniker range=">= aspnetcore-8.0"
1267+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
12281268

12291269
Blazor Web App:
12301270

1271+
:::moniker-end
1272+
1273+
:::moniker range=">= aspnetcore-8.0"
1274+
12311275
```html
12321276
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
12331277
<script>
@@ -1242,10 +1286,16 @@ Blazor Web App:
12421286
</script>
12431287
```
12441288

1289+
:::moniker-end
1290+
1291+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1292+
12451293
Blazor Server:
12461294

12471295
:::moniker-end
12481296

1297+
:::moniker range="< aspnetcore-10.0"
1298+
12491299
```html
12501300
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
12511301
<script>
@@ -1258,6 +1308,8 @@ Blazor Server:
12581308
</script>
12591309
```
12601310

1311+
:::moniker-end
1312+
12611313
**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 <xref:blazor/project-structure#location-of-the-blazor-script>.
12621314

12631315
:::moniker range=">= aspnetcore-9.0"
@@ -1369,8 +1421,16 @@ The server timeout can be increased, and the Keep-Alive interval can remain the
13691421

13701422
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.
13711423

1424+
:::moniker-end
1425+
1426+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1427+
13721428
Blazor Web App:
13731429

1430+
:::moniker-end
1431+
1432+
:::moniker range=">= aspnetcore-8.0"
1433+
13741434
```html
13751435
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
13761436
<script>
@@ -1384,8 +1444,16 @@ Blazor Web App:
13841444
</script>
13851445
```
13861446

1447+
:::moniker-end
1448+
1449+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1450+
13871451
Blazor Server:
13881452

1453+
:::moniker-end
1454+
1455+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1456+
13891457
```html
13901458
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
13911459
<script>
@@ -1397,6 +1465,10 @@ Blazor Server:
13971465
</script>
13981466
```
13991467

1468+
:::moniker-end
1469+
1470+
:::moniker range=">= aspnetcore-8.0"
1471+
14001472
When creating a hub connection in a component, set the server timeout (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilderExtensions.WithServerTimeout%2A>, default: 30 seconds) on the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder>. Set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeTimeout> (default: 15 seconds) on the built <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>. Confirm that the timeouts are at least double the Keep-Alive interval (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilderExtensions.WithKeepAliveInterval%2A>/<xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.KeepAliveInterval>) and that the Keep-Alive value matches between server and client.
14011473

14021474
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 <xref:Microsoft.AspNetCore.Components.Server.Circuits.CircuitHandler> to c
15351607

15361608
Prevent automatically starting the app by adding `autostart="false"` to the Blazor `<script>` tag ([location of the Blazor start script](xref:blazor/project-structure#location-of-the-blazor-script)). Manually establish the circuit URL using `Blazor.start`. The following examples use the path `/signalr`.
15371609

1538-
:::moniker range=">= aspnetcore-8.0"
1610+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
15391611

1540-
Blazor Web Apps:
1612+
Blazor Web App:
1613+
1614+
:::moniker-end
1615+
1616+
:::moniker range=">= aspnetcore-8.0"
15411617

15421618
```diff
1543-
- <script src="_framework/blazor.web.js"></script>
1544-
+ <script src="_framework/blazor.web.js" autostart="false"></script>
1619+
- <script src="{BLAZOR SCRIPT}"></script>
1620+
+ <script src="{BLAZOR SCRIPT}" autostart="false"></script>
15451621
+ <script>
15461622
+ Blazor.start({
15471623
+ circuit: {
@@ -1551,20 +1627,30 @@ Blazor Web Apps:
15511627
+ </script>
15521628
```
15531629

1630+
:::moniker-end
1631+
1632+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1633+
15541634
Blazor Server:
15551635

15561636
:::moniker-end
15571637

1638+
:::moniker range="< aspnetcore-10.0"
1639+
15581640
```diff
1559-
- <script src="_framework/blazor.server.js"></script>
1560-
+ <script src="_framework/blazor.server.js" autostart="false"></script>
1641+
- <script src="{BLAZOR SCRIPT}"></script>
1642+
+ <script src="{BLAZOR SCRIPT}" autostart="false"></script>
15611643
+ <script>
15621644
+ Blazor.start({
15631645
+ configureSignalR: builder => builder.withUrl("/signalr")
15641646
+ });
15651647
+ </script>
15661648
```
15671649

1650+
:::moniker-end
1651+
1652+
**In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script, see <xref:blazor/project-structure#location-of-the-blazor-script>.
1653+
15681654
Add the following <xref:Microsoft.AspNetCore.Builder.ComponentEndpointRouteBuilderExtensions.MapBlazorHub%2A> call with the hub path to the middleware processing pipeline in the server app's `Program` file.
15691655

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

0 commit comments

Comments
 (0)