Skip to content

Commit 25c532c

Browse files
authored
[10.0] Improve the location of the Blazor script section (#36319)
1 parent cbf1b59 commit 25c532c

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

aspnetcore/blazor/project-structure.md

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,19 +540,27 @@ The project structure of the client-side app in a hosted Blazor Webassembly solu
540540

541541
The Blazor script is served as a static web asset with automatic compression and fingerprinting. For more information, see <xref:blazor/fundamentals/static-files>.
542542

543-
:::moniker-end
543+
In a Blazor Web App, the Blazor script is located in the `Components/App.razor` file:
544544

545-
:::moniker range="< aspnetcore-10.0"
545+
```razor
546+
<script src="@Assets["_framework/blazor.web.js"]"></script>
547+
```
546548

547-
The Blazor script is served from an embedded resource in the ASP.NET Core shared framework.
549+
In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml` file:
550+
551+
```html
552+
<script src="_framework/blazor.server.js"></script>
553+
```
548554

549555
:::moniker-end
550556

551-
:::moniker range=">= aspnetcore-8.0"
557+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
558+
559+
The Blazor script is served from an embedded resource in the ASP.NET Core shared framework.
552560

553561
In a Blazor Web App, the Blazor script is located in the `Components/App.razor` file:
554562

555-
```html
563+
```razor
556564
<script src="_framework/blazor.web.js"></script>
557565
```
558566

@@ -566,6 +574,8 @@ In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml`
566574

567575
:::moniker range=">= aspnetcore-7.0 < aspnetcore-8.0"
568576

577+
The Blazor script is served from an embedded resource in the ASP.NET Core shared framework.
578+
569579
In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml` file:
570580

571581
```html
@@ -576,6 +586,8 @@ In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml`
576586

577587
:::moniker range=">= aspnetcore-6.0 < aspnetcore-7.0"
578588

589+
The Blazor script is served from an embedded resource in the ASP.NET Core shared framework.
590+
579591
In a Blazor Server app, the Blazor script is located in the `Pages/_Layout.cshtml` file:
580592

581593
```html
@@ -586,6 +598,8 @@ In a Blazor Server app, the Blazor script is located in the `Pages/_Layout.cshtm
586598

587599
:::moniker range="< aspnetcore-6.0"
588600

601+
The Blazor script is served from an embedded resource in the ASP.NET Core shared framework.
602+
589603
In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml` file:
590604

591605
```html
@@ -594,18 +608,32 @@ In a Blazor Server app, the Blazor script is located in the `Pages/_Host.cshtml`
594608

595609
:::moniker-end
596610

611+
For a Blazor Web App or a Blazor Server app, the project must contain at least one Razor component file (`.razor`) in order to automatically include the Blazor script when the app is published. If the project doesn't contain at least one Razor component, set the `RequiresAspNetWebAssets` MSBuild property to `true` in the app's project file to include the Blazor script:
612+
613+
```xml
614+
<RequiresAspNetWebAssets>true</RequiresAspNetWebAssets>
615+
```
616+
597617
In a Blazor WebAssembly app, the Blazor script content is located in the `wwwroot/index.html` file:
598618

619+
:::moniker range=">= aspnetcore-10.0"
620+
599621
```html
600-
<script src="_framework/blazor.webassembly.js"></script>
622+
<script src="_framework/blazor.webassembly#[.{fingerprint}].js"></script>
601623
```
602624

603-
For a Blazor Web App or a Blazor Server app, the project must contain at least one Razor component file (`.razor`) in order to automatically include the Blazor script when the app is published. If the project doesn't contain at least one Razor component, set the `RequiresAspNetWebAssets` MSBuild property `true` in the app's project file to include the Blazor script:
625+
When the app is published, the `{fingerprint}` placeholder is automatically replaced with a unique hash for cache busting.
604626

605-
```xml
606-
<RequiresAspNetWebAssets>true</RequiresAspNetWebAssets>
627+
:::moniker-end
628+
629+
:::moniker range="< aspnetcore-10.0"
630+
631+
```html
632+
<script src="_framework/blazor.webassembly.js"></script>
607633
```
608634

635+
:::moniker-end
636+
609637
## Location of `<head>` and `<body>` content
610638

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

0 commit comments

Comments
 (0)