Skip to content

Commit c9c64aa

Browse files
committed
Blazor startup options format
1 parent cd02708 commit c9c64aa

File tree

6 files changed

+216
-18
lines changed

6 files changed

+216
-18
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
@@ -806,8 +806,16 @@ Configure the following values for the client:
806806

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

809+
:::moniker-end
810+
811+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
812+
809813
Blazor Web App:
810814

815+
:::moniker-end
816+
817+
:::moniker range=">= aspnetcore-8.0
818+
811819
```html
812820
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
813821
<script>
@@ -823,8 +831,16 @@ Blazor Web App:
823831

824832
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).
825833

834+
:::moniker-end
835+
836+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
837+
826838
Blazor Server:
827839

840+
:::moniker-end
841+
842+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
843+
828844
```html
829845
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
830846
<script>
@@ -836,6 +852,10 @@ Blazor Server:
836852
</script>
837853
```
838854

855+
:::moniker-end
856+
857+
:::moniker range=">= aspnetcore-8.0
858+
839859
**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>.
840860

841861
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:
@@ -931,10 +951,14 @@ To modify the connection events, register callbacks for the following connection
931951

932952
**Both `onConnectionDown` and `onConnectionUp` must be specified.**
933953

934-
:::moniker range=">= aspnetcore-8.0"
954+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
935955

936956
Blazor Web App:
937957

958+
:::moniker-end
959+
960+
:::moniker range=">= aspnetcore-8.0"
961+
938962
```html
939963
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
940964
<script>
@@ -949,10 +973,16 @@ Blazor Web App:
949973
</script>
950974
```
951975

976+
:::moniker-end
977+
978+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
979+
952980
Blazor Server:
953981

954982
:::moniker-end
955983

984+
:::moniker range="< aspnetcore-10.0"
985+
956986
```html
957987
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
958988
<script>
@@ -965,6 +995,8 @@ Blazor Server:
965995
</script>
966996
```
967997

998+
:::moniker-end
999+
9681000
**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>.
9691001

9701002
:::moniker range=">= aspnetcore-7.0"
@@ -1001,10 +1033,14 @@ Create the following `wwwroot/boot.js` file.
10011033

10021034
:::moniker-end
10031035

1004-
:::moniker range=">= aspnetcore-8.0"
1036+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
10051037

10061038
Blazor Web App:
10071039

1040+
:::moniker-end
1041+
1042+
:::moniker range=">= aspnetcore-8.0"
1043+
10081044
```javascript
10091045
(() => {
10101046
const maximumRetryCount = 3;
@@ -1069,11 +1105,15 @@ Blazor Web App:
10691105
})();
10701106
```
10711107

1108+
:::moniker-end
1109+
1110+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1111+
10721112
Blazor Server:
10731113

10741114
:::moniker-end
10751115

1076-
:::moniker range=">= aspnetcore-7.0"
1116+
:::moniker range=">= aspnetcore-7.0 < aspnetcore-10.0"
10771117

10781118
```javascript
10791119
(() => {
@@ -1145,10 +1185,14 @@ For more information on Blazor startup, see <xref:blazor/fundamentals/startup>.
11451185

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

1148-
:::moniker range=">= aspnetcore-8.0"
1188+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
11491189

11501190
Blazor Web App:
11511191

1192+
:::moniker-end
1193+
1194+
:::moniker range=">= aspnetcore-8.0"
1195+
11521196
```html
11531197
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
11541198
<script>
@@ -1163,10 +1207,16 @@ Blazor Web App:
11631207
</script>
11641208
```
11651209

1210+
:::moniker-end
1211+
1212+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1213+
11661214
Blazor Server:
11671215

11681216
:::moniker-end
11691217

1218+
:::moniker range="< aspnetcore-10.0"
1219+
11701220
```html
11711221
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
11721222
<script>
@@ -1179,6 +1229,8 @@ Blazor Server:
11791229
</script>
11801230
```
11811231

1232+
:::moniker-end
1233+
11821234
**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>.
11831235

11841236
:::moniker range=">= aspnetcore-9.0"
@@ -1290,8 +1342,16 @@ The server timeout can be increased, and the Keep-Alive interval can remain the
12901342

12911343
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.
12921344

1345+
:::moniker-end
1346+
1347+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1348+
12931349
Blazor Web App:
12941350

1351+
:::moniker-end
1352+
1353+
:::moniker range=">= aspnetcore-8.0"
1354+
12951355
```html
12961356
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
12971357
<script>
@@ -1305,8 +1365,16 @@ Blazor Web App:
13051365
</script>
13061366
```
13071367

1368+
:::moniker-end
1369+
1370+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1371+
13081372
Blazor Server:
13091373

1374+
:::moniker-end
1375+
1376+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1377+
13101378
```html
13111379
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
13121380
<script>
@@ -1318,6 +1386,10 @@ Blazor Server:
13181386
</script>
13191387
```
13201388

1389+
:::moniker-end
1390+
1391+
:::moniker range=">= aspnetcore-8.0"
1392+
13211393
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.
13221394

13231395
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.
@@ -1456,13 +1528,17 @@ Use a <xref:Microsoft.AspNetCore.Components.Server.Circuits.CircuitHandler> to c
14561528

14571529
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`.
14581530

1459-
:::moniker range=">= aspnetcore-8.0"
1531+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
14601532

1461-
Blazor Web Apps:
1533+
Blazor Web App:
1534+
1535+
:::moniker-end
1536+
1537+
:::moniker range=">= aspnetcore-8.0"
14621538

14631539
```diff
1464-
- <script src="_framework/blazor.web.js"></script>
1465-
+ <script src="_framework/blazor.web.js" autostart="false"></script>
1540+
- <script src="{BLAZOR SCRIPT}"></script>
1541+
+ <script src="{BLAZOR SCRIPT}" autostart="false"></script>
14661542
+ <script>
14671543
+ Blazor.start({
14681544
+ circuit: {
@@ -1472,20 +1548,30 @@ Blazor Web Apps:
14721548
+ </script>
14731549
```
14741550

1551+
:::moniker-end
1552+
1553+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
1554+
14751555
Blazor Server:
14761556

14771557
:::moniker-end
14781558

1559+
:::moniker range="< aspnetcore-10.0"
1560+
14791561
```diff
1480-
- <script src="_framework/blazor.server.js"></script>
1481-
+ <script src="_framework/blazor.server.js" autostart="false"></script>
1562+
- <script src="{BLAZOR SCRIPT}"></script>
1563+
+ <script src="{BLAZOR SCRIPT}" autostart="false"></script>
14821564
+ <script>
14831565
+ Blazor.start({
14841566
+ configureSignalR: builder => builder.withUrl("/signalr")
14851567
+ });
14861568
+ </script>
14871569
```
14881570

1571+
:::moniker-end
1572+
1573+
**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>.
1574+
14891575
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.
14901576

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

0 commit comments

Comments
 (0)