Skip to content

Commit e41f5bc

Browse files
authored
[11.0 P1] Blazor startup options format (#36581)
1 parent fffcdbf commit e41f5bc

6 files changed

Lines changed: 286 additions & 26 deletions

File tree

aspnetcore/blazor/fundamentals/environments.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ For general guidance on ASP.NET Core app configuration, see <xref:fundamentals/e
124124

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

127-
:::moniker range=">= aspnetcore-8.0"
127+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-11.0"
128128

129129
Blazor Web App:
130130

131+
:::moniker-end
132+
133+
:::moniker range=">= aspnetcore-8.0"
134+
131135
```html
132136
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
133137
<script>
@@ -148,10 +152,16 @@ Blazor Web App:
148152
> [!NOTE]
149153
> 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 operates 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>.
150154
155+
:::moniker-end
156+
157+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-11.0"
158+
151159
Standalone Blazor WebAssembly:
152160

153161
:::moniker-end
154162

163+
:::moniker range="< aspnetcore-11.0"
164+
155165
```html
156166
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
157167
<script>
@@ -167,6 +177,8 @@ Standalone Blazor WebAssembly:
167177

168178
**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>.
169179

180+
:::moniker-end
181+
170182
:::moniker range="< aspnetcore-10.0"
171183

172184
Using the `environment` property overrides the environment set by the [`Blazor-Environment` header](#set-the-client-side-environment-via-header).
@@ -175,7 +187,7 @@ The preceding approach sets the client's environment without changing the `Blazo
175187

176188
:::moniker-end
177189

178-
To log the environment to the console in either a standalone Blazor WebAssembly app or the `.Client` project of a Blazor Web App, place the following C# code in the `Program` file after the <xref:Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost> is created with <xref:Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.CreateDefault%2A?displayProperty=nameWithType> and before the line that builds and runs the project (`await builder.Build().RunAsync();`):
190+
To log the environment to the console in either a standalone Blazor WebAssembly app (all release versions) or the `.Client` project of a Blazor Web App (.NET 8 or later), place the following C# code in the `Program` file after the <xref:Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost> is created with <xref:Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.CreateDefault%2A?displayProperty=nameWithType> and before the line that builds and runs the project (`await builder.Build().RunAsync();`):
179191

180192
```csharp
181193
Console.WriteLine(

aspnetcore/blazor/fundamentals/logging.md

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

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

580-
:::moniker range=">= aspnetcore-8.0"
580+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-11.0"
581581

582582
Blazor Web App:
583583

584+
:::moniker-end
585+
586+
:::moniker range=">= aspnetcore-8.0"
587+
584588
```html
585589
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
586590
<script>
@@ -594,10 +598,16 @@ Blazor Web App:
594598
</script>
595599
```
596600

601+
:::moniker-end
602+
603+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-11.0"
604+
597605
Blazor Server:
598606

599607
:::moniker-end
600608

609+
:::moniker range="< aspnetcore-11.0"
610+
601611
```html
602612
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
603613
<script>
@@ -609,14 +619,20 @@ Blazor Server:
609619
</script>
610620
```
611621

622+
:::moniker-end
623+
612624
**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>.
613625

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

616-
:::moniker range=">= aspnetcore-8.0"
628+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-11.0"
617629

618630
Blazor Web App:
619631

632+
:::moniker-end
633+
634+
:::moniker range=">= aspnetcore-8.0"
635+
620636
```html
621637
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
622638
<script>
@@ -630,10 +646,18 @@ Blazor Web App:
630646
</script>
631647
```
632648

649+
**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>.
650+
651+
:::moniker-end
652+
653+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-11.0"
654+
633655
Blazor Server:
634656

635657
:::moniker-end
636658

659+
:::moniker range="< aspnetcore-11.0"
660+
637661
```html
638662
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
639663
<script>
@@ -647,6 +671,8 @@ Blazor Server:
647671

648672
**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>.
649673

674+
:::moniker-end
675+
650676
> [!NOTE]
651677
> Using an integer to specify the logging level in Example 2, often referred to as a *magic number* or *magic constant*, is considered a poor coding practice because the integer doesn't clearly identify the logging level when viewing the source code. If minimizing the bytes transferred to the browser is a priority, using an integer might be justified (consider removing the comment in such cases).
652678

0 commit comments

Comments
 (0)