You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are registering any services (except HttpClient that isn't specially configured) to the service provider at the startup of your Blazor WebAssembly app, please extract that process to the static method named `static void ConfigureServices(IServiceCollection services, string baseAddress)`.
And, if you implement the entry point as C# 9 top-level statement style, then you have to also extract the service-registration process to the static local function named `static void ConfigureServices(IServiceCollection services, string baseAddress)`.
73
-
74
-
> _**NOTICE:** The "ConfigureServices" local function must be **"static"** local function._
33
+
In the `Program.cs` of your Blazor WebAssembly app, you must extract the service registration part into the static local function named `static void ConfigureServices(IServiceCollection services, string baseAddress)`, like below.
75
34
76
35
```csharp
77
-
//The "Program.cs" that is C# 9 top-level statement style entry point.
> _Aside: C# 9 top-level statement style entry point can be used for only .NET6 or above._
54
+
This package calls the `ConfigureServices(...)` static local function inside of your Blazor WebAssembly app when the pre-rendering process starts if that function exists.
95
55
96
-
This package calls the `ConfigureServices()` static method (or static local function) inside of your Blazor WebAssembly app when pre-renders it if that method exists.
56
+
This is important for your Blazor WebAssembly components to work fine in the pre-rendering process.
97
57
98
-
This is important to your Blazor WebAssembly components work fine in the pre-rendering process.
58
+
#### Note: other arguments of ConfigureServices() function
99
59
100
-
#### Note: other arguments of ConfigureServices() method
101
-
102
-
The `ConfigureServices()` method can also have an `IConfiguration` argument reflected with the contents of the `wwwroot/appsetting.json` JSON file.
60
+
The `ConfigureServices(...)` static local function can also have an `IConfiguration` argument that reflects the contents of the `wwwroot/appsetting.json` JSON file.
103
61
104
62
### Root component type and selector
105
63
@@ -235,7 +193,7 @@ To support that case, please **set the URL path list that you want to fetch expl
235
193
236
194
As you may know, this package is based on the standard ASP.NET Core Blazor server-side prerendering support.
237
195
238
-
- See also: ["Prerender and integrate ASP.NET Core Razor components | Microsoft Docs"](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/prerendering-and-integration?view=aspnetcore-6.0&pivots=webassembly)
196
+
- See also: ["Prerender and integrate ASP.NET Core Razor components | Microsoft Learn"](https://learn.microsoft.com/aspnet/core/blazor/components/prerendering-and-integration?pivots=webassembly)
239
197
240
198
By default, the render mode of prerendering is `Static`.
241
199
And, **you can specify the render mode to `WebAssemblyPrerendered` via the `BlazorWasmPrerenderingMode` MSBuild property** if you want.
@@ -275,7 +233,7 @@ if (!builder.RootComponents.Any())
275
233
276
234
That is because the root component types and their insertion positions are specified inside of the prerendered HTML contents, not inside of your C# code when the render mode is `WebAssemblyPrerendered`.
277
235
278
-
Moreover, on .NET 6, you can also use the **"persisting prerendered state"** feature.
236
+
Moreover, you can also use the **"persisting prerendered state"** feature.
279
237
280
238
When the render mode is `WebAssemblyPrerendered`, this package injects the `<persist-component-state />` tag helper into the fallback page.
281
239
@@ -452,19 +410,10 @@ During the prerendering process is running, developers can investigate it.
452
410
## 🔗Appendix
453
411
454
412
- If you would like to **change a title or any meta elements** for each page in your Blazor WebAssembly app, I recommend using the [**"Blazor Head Element Helper"**](https://www.nuget.org/packages/Toolbelt.Blazor.HeadElement/) NuGet package.
455
-
- Since the ver.1.0.0 preview 8 of this package, **the .NET 6`<PageTitle>` and `<HeadContent>` components** are also statically pre-rendered properly.
413
+
-**The`<PageTitle>` and `<HeadContent>` components** are also statically pre-rendered properly.
456
414
- If you would like to deploy your Blazor WebAssembly app to **GitHub Pages**, I recommend using the [**"Publish SPA for GitHub Pages"**](https://www.nuget.org/packages/PublishSPAforGitHubPages.Build/) NuGet package.
457
415
- The **["Awesome Blazor Browser"](https://jsakamoto.github.io/awesome-blazor-browser/)** site is one of a good showcase of this package. That site is republishing every day by GitHub Actions with pre-rendering powered by this package.
458
416
459
-
## ⚠️Notice
460
-
461
-
This package is now experimental stage.
462
-
463
-
We can expect this package will work fine with a simple Blazor WebAssembly project.
464
-
But I'm not sure this package works fine even with a complicated real-world Blazor WebAssembly project at this time.
465
-
466
-
I welcome to fork and improve this project on your hand.
0 commit comments