### Fetch Data Example Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/BlazorWasmPreRendering.Build.Test/_Fixtures/TestSites/Site1/wwwroot/fetchdata/weather-forecast/index.html Demonstrates fetching data in a Blazor WASM application. ```html Fetch Data Fetch Data ========== [Home](./) [Counter](./counter) ``` -------------------------------- ### Install BlazorWasmPreRendering.Build Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Command to install the BlazorWasmPreRendering.Build NuGet package using the .NET CLI. This is the primary step to enable pre-rendering for your Blazor WebAssembly application. ```bash dotnet add package BlazorWasmPreRendering.Build ``` -------------------------------- ### BlazorWasmApp Structure Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmLazyLoading/BlazorWasmApp/wwwroot/index.html This snippet outlines the basic structure of a Blazor WebAssembly application, likely including project files and key directories. It serves as a starting point for understanding the project's organization. ```text Project: /jsakamoto/blazorwasmprerendering.build Content: BlazorWasmApp An unhandled error has occurred. Reload πŸ—™ ``` -------------------------------- ### ConfigureServices Extraction for Pre-rendering Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Example of modifying the `Program.cs` file in a Blazor WebAssembly project to extract the service registration logic into a static local function named `ConfigureServices`. This is a prerequisite for the BlazorWasmPreRendering.Build package to function correctly during the pre-rendering process. ```csharp // Program.cs var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress); await builder.Build().RunAsync(); // πŸ‘‡ extract the service-registration process to the static local function. static void ConfigureServices(IServiceCollection services, string baseAddress) { services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) }); services.AddScoped(); } ``` -------------------------------- ### Setting MSBuild Properties via Environment Variables (Bash) Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/MSBUILD-PROPERTIES.md Example of setting MSBuild properties as environment variables using Bash. ```bash # An example for Bash > export BlazorWasmPrerendering="true" > export BlazorWasmPrerenderingRootComponentType="MyNamespace.MyApp" ... ``` -------------------------------- ### Setting MSBuild Properties via Environment Variables (PowerShell) Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/MSBUILD-PROPERTIES.md Example of setting MSBuild properties as environment variables using PowerShell. ```powershell # An example for PowerShell > $env:BlazorWasmPrerendering = "true" > $env:BlazorWasmPrerenderingRootComponentType = "MyNamespace.MyApp" ... ``` -------------------------------- ### Setting MSBuild Properties in Project File Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/MSBUILD-PROPERTIES.md Example of how to specify MSBuild properties and their values within a .csproj file. ```xml ... true MyNamespace.MyApp ... ... ``` -------------------------------- ### Blazor WASM Prerendering: Configuration Service Injection Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt Introduces the provision of an IConfiguration object to the application's ConfigureServices() method. This allows for better configuration management within the Blazor WebAssembly prerendering setup. ```csharp // Version: v.1.0.0-preview.11.4 // Change: An IConfiguration object will be provided to the application's "ConfigureServices()" method as an argument. ``` -------------------------------- ### Blazor WASM Prerendering: .NET 6 RC2 Upgrade and SDK Transformation Fix Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt This version upgrades .NET 6 support to Release Candidate 2 (RC2). It also resolves an issue where the transformation process ran twice when the wasm-tools workload was installed in the .NET 6 SDK. ```csharp // Version: v.1.0.0-preview.9 // Changes: // - Upgrade .NET6 support to RC2. // - Fix: in .NET 6 SDK that wasm-tools workload is installed, the transformation runs twice. ``` -------------------------------- ### ConfigureServices with IWebAssemblyHostEnvironment and IConfiguration Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Demonstrates how to modify the `ConfigureServices` static local function to accept `IWebAssemblyHostEnvironment` and `IConfiguration` arguments. This allows access to environment information (like environment name and base address) and application configuration settings within the pre-rendering context. ```csharp // Program.cs ... ConfigureServices(builder.Services, builder.HostEnvironment, builder.Configuration); ... static void ConfigureServices(IServiceCollection services, IWebAssemblyHostEnvironment webHostEnv, IConfiguration configuration) { // You can get the environment name via "webHostEnv.Environment". // You can also get the app base address via "webHostEnv.BaseAddress". ... } ``` -------------------------------- ### BlazorWasmApp1 Details Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/SAMPLE-APPS-README.md Details for BlazorWasmApp1, including its framework version (.NET 9.0), project structure (Client), root element ('
'), E2E test usage, page title element (''), PWA support, easter-egg presence, GitHub Pages deployment, Brotli loader, AngleSharp dependency, localization, and lazy load assembly. ```APIDOC BlazorWasmApp1: Framework: .NET 9.0 Projects: Client Root element: <div id='app'> Used in E2E test: Yes Page title: <Title> PWA: No Has easter-egg: Yes Deploy to GitHub Pages: Yes Brotli Loader: No Has AngleSharp dependency: No Localization: No Lazy Load Assembly: Yes ``` -------------------------------- ### Program.cs Configuration for Lazy Loading Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md This C# code configures the Blazor WASM host. It registers the `LazyLoader` service as a singleton and then invokes its `PreloadAsync` method before running the host. This ensures that any necessary lazy assemblies are loaded upfront, contributing to a smoother initial render. ```csharp using BlazorWasmApp; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; var builder = WebAssemblyHostBuilder.CreateDefault(args); if (!builder.RootComponents.Any()) { builder.RootComponents.Add<App>("#app"); builder.RootComponents.Add<HeadOutlet>("head::after"); } ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress); var host = builder.Build(); // πŸ‘‡ Invoke the "PreloadAsync" method of the "LazyLoader" service // to preload lazy assemblies needed for the current URL path before running. var lazyLoader = host.Services.GetRequiredService<LazyLoader>(); await lazyLoader.PreloadAsync(); await host.RunAsync(); static void ConfigureServices(IServiceCollection services, string baseAddress) { // πŸ‘‡ Register the "LazyLoader" service services.AddSingleton<LazyLoader>(); services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) }); } ``` -------------------------------- ### BlazorWasmApp0 Details Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/SAMPLE-APPS-README.md Details for BlazorWasmApp0, including its framework version (.NET 8.0), project structure (Client + RCLIb), root element ('<app>'), E2E test usage, page title element ('<PageTitle>'), PWA support, easter-egg presence, GitHub Pages deployment, Brotli loader, AngleSharp dependency, localization, and lazy load assembly. ```APIDOC BlazorWasmApp0: Framework: .NET 8.0 Projects: Client + RCLIb Root element: <app> Used in E2E test: Yes Page title: <PageTitle> PWA: Yes Has easter-egg: No Deploy to GitHub Pages: No Brotli Loader: Yes Has AngleSharp dependency: Yes Localization: Yes Lazy Load Assembly: Yes Appendix: - The razor class library referenced from the BlazorWasmApp0 project has AssemblyMetadata attributes to install middleware packages Middleware1 ver.1.0 and Middleware2 ver.2.0. ``` -------------------------------- ### BlazorWasmApp2 Details Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/SAMPLE-APPS-README.md Details for BlazorWasmApp2, including its framework version (.NET 6.0), project structure (Component + Client), root element ('<app>'), E2E test usage, page title element (not specified), PWA support, easter-egg presence, GitHub Pages deployment, Brotli loader, AngleSharp dependency, localization, and lazy load assembly. ```APIDOC BlazorWasmApp2: Framework: .NET 6.0 Projects: Component + Client Root element: <app> Used in E2E test: Yes Page title: - PWA: No Has easter-egg: No Deploy to GitHub Pages: No Brotli Loader: No Has AngleSharp dependency: No Localization: No Lazy Load Assembly: Yes Appendix: - Consists from the component library project and the Blazor WebAssembly project. - The component libray project defines the interface. - The Blazor Wasm project implements that interface and register it to a DI container. ``` -------------------------------- ### Troubleshooting Prerendering Exceptions Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md To investigate living prerendering processes when exceptions occur, set the `BlazorWasmPrerenderingKeepServer` MSBuild property to `true` during `dotnet publish`. This keeps the prerendering process running until Ctrl+C is pressed, allowing for live inspection. ```shell dotnet publish -c:Release -p:BlazorWasmPrerenderingKeepServer=true ``` -------------------------------- ### Setting MSBuild Properties via dotnet publish Command Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/MSBUILD-PROPERTIES.md Demonstrates how to set MSBuild properties using the -p command-line option with the 'dotnet publish' command. ```shell dotnet publish -c:Release -p:BlazorWasmPrerendering=true -p:BlazorWasmPrerenderingRootComponentType=MyNamespace.MyApp ... ``` -------------------------------- ### Related MSBuild Properties and Packages Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md This section references external resources and packages relevant to Blazor WebAssembly development, including MSBuild properties for prerendering, managing head elements, deploying to GitHub Pages, and a showcase site. ```markdown - [_MSBuild properties reference for the "BlazorWasmPreRendering.Build"_](https://github.com/jsakamoto/BlazorWasmPreRendering.Build/blob/master/MSBUILD-PROPERTIES.md) - ["Blazor Head Element Helper" ![NuGet Package](https://img.shields.io/nuget/v/Toolbelt.Blazor.HeadElement.svg)](https://www.nuget.org/packages/Toolbelt.Blazor.HeadElement/) - ["Publish SPA for GitHub Pages" ![NuGet Package](https://img.shields.io/nuget/v/PublishSPAforGitHubPages.Build.svg)](https://www.nuget.org/packages/PublishSPAforGitHubPages.Build/) - ["Awesome Blazor Browser"](https://jsakamoto.github.io/awesome-blazor-browser/) ``` -------------------------------- ### Explicitly Fetch URL Paths Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Configure the `BlazorWasmPrerenderingUrlPathToExplicitFetch` MSBuild property with a semicolon-separated string of URL paths. This ensures that specified pages are fetched and saved as static HTML files, even if they are not linked from anywhere within the application. ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <!-- πŸ‘‡ If you set this, each URL path will be fetched and saved as a static HTML file even if those URLs are not linked from anywhere. --> <BlazorWasmPrerenderingUrlPathToExplicitFetch>/unkinked/page1;/unlinked/page2</BlazorWasmPrerenderingUrlPathToExplicitFetch> ... ``` -------------------------------- ### Open Iconic with Foundation Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp1/wwwroot/css/open-iconic/README.md Details the integration of Open Iconic with the Foundation framework. Shows how to include the Foundation stylesheet and apply the corresponding icon classes. ```html <link href="/open-iconic/font/css/open-iconic-foundation.css" rel="stylesheet"> <span class="fi-icon-name" title="icon name" aria-hidden="true"></span> ``` -------------------------------- ### BlazorWasmApp2.Client Project Structure Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp2/Client/wwwroot/index.html Represents the client-side project within the Blazor WASM Prerendering build. This typically includes the main application components, services, and static assets. ```csharp namespace BlazorWasmApp2.Client { // Client-side application code goes here } ``` -------------------------------- ### Blazor WASM Prerendering: Initial Release Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt Marks the first release of the Blazor WebAssembly Prerendering project. ```csharp // Version: v.1.0.0-preview.4.1 // Change: 1st release. ``` -------------------------------- ### Client-Side Loading and Error Handling Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp2/Client/wwwroot/index.html Demonstrates the typical UI states for loading and error handling in a Blazor WebAssembly application's client-side component. This includes visual feedback for ongoing operations and user-friendly messages for unhandled errors. ```html <div> Loading... </div> <p> An unhandled error has occurred. Reload πŸ—™ </p> ``` -------------------------------- ### Using Open Iconic SVG Sprite Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmLazyLoading/BlazorWasmApp/wwwroot/css/open-iconic/README.md Illustrates the usage of Open Iconic's SVG sprite for displaying icons. This approach allows for a single request for all icons and uses the `<use>` tag with `xlink:href` to reference specific icons. It also shows how to style and size icons using CSS. ```html <svg class="icon"> <use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use> </svg> ``` ```css .icon { width: 16px; height: 16px; } .icon-account-login { fill: #f00; } ``` -------------------------------- ### Open Iconic with Bootstrap Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp1/wwwroot/css/open-iconic/README.md Provides instructions for integrating Open Iconic with the Bootstrap framework. Includes linking the Bootstrap-specific stylesheet and using the icon classes. ```html <link href="/open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet"> <span class="oi oi-icon-name" title="icon name" aria-hidden="true"></span> ``` -------------------------------- ### Open Iconic with Foundation Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmLazyLoading/BlazorWasmApp/wwwroot/css/open-iconic/README.md Demonstrates the integration of Open Iconic with the Foundation framework. This involves linking the Foundation-specific stylesheet and applying the appropriate classes to `<span>` elements. ```html <link href="/open-iconic/font/css/open-iconic-foundation.css" rel="stylesheet"> <span class="fi-icon-name" title="icon name" aria-hidden="true"></span> ``` -------------------------------- ### Display Hosting Environment in Blazor WASM Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Demonstrates how to access and display the hosting environment name during Blazor WebAssembly prerendering. The environment name is 'Prerendering' by default. ```html @inject IWebAssemblyHostEnvironment HostEnv <p>@HostEnv.Environment</p> <!-- ↑ This will be pre-rendered as "<p>Prerendering</p>". --> ``` -------------------------------- ### MSBuild Properties for BlazorWasmPreRendering Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/MSBUILD-PROPERTIES.md Lists and describes MSBuild properties for configuring Blazor WebAssembly prerendering. Includes default values and explanations for each property. ```APIDOC BlazorWasmPrerendering: Description: Set the `disable` to suppress prerendering. Default Value: (empty) BlazorWasmPrererenderingRootComponentType: Description: Set the full name (including namespace) of a root component class. Default Value: `$(RootNamespace).App` BlazorWasmPrerenderingRootComponentSelector: Description: Set the DOM element selector for attaching the root component. Default Value: `#app,app` BlazorWasmPrerenderingHeadOutletComponentSelector: Description: Set the DOM element selector for attaching the `<HeadOutlet>` component of the Blazor. Default Value: `head::after` BlazorWasmPrerenderingOutputStyle: Description: When it is set to `AppendHtmlExtension`, the page of the URL path `foo/bar` will be saved as the `foo/bar.html` instead of the `foo/bar/index.html`. Default Value: `IndexHtmlInSubFolders` BlazorWasmPrerenderingDeleteLoadingContents: Description: When it is set to `true`, the "Loading..." contents will be deleted from prerendered output HTML files, and prerendered contents to be visible immediately even before the Blazor WebAssembly runtime has warmed up. Default Value: `false` BlazorWasmPrerenderingUrlPathToExplicitFetch: Description: Set the semicolon-separated URL paths explicitly that are not linked from anywhere, such as easter-egg pages, to be prerendered. Default Value: (empty) BlazorWasmPrerenderingEnvironment: Description: Set a name of a host environment that can retrieve via `IWebHostEnvironment.Environment`. Default Value: `Prerendering` BlazorWasmPrerenderingEmulateAuthMe: Description: When it is set to `true`, prerendering server emulates Azure App Services Auth. That means the ULR endpoint **"/.auth/me"** will return the JSON content `{"clientPrincipal":null}`. Default Value: `true` BlazorWasmPrerenderingLocale: Description: Set a comma-separated locale list such as "en", "ja-JP,en-US", etc., those used when crawling. **⚠️Attention:** when you specify this MSBuild property via "dotnet" command line, you have to replace `,` (comma) with `%2c`. Default Value: `en` BlazorWasmPrerenderingMode: Description: Set the render mode in which `Static` or `WebAssemblyPrerendered`. Default Value: `Static` BlazorWasmPrerenderingKeepServer: Description: When it is set to `true`, the `dotnet publish` command will not be exited, and the prerendering server process will keep running until `Ctrl` + `C` is pressed. Default Value: `false` ``` -------------------------------- ### Standalone Open Iconic Usage Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmLazyLoading/BlazorWasmApp/wwwroot/css/open-iconic/README.md Explains how to use Open Iconic independently without frameworks like Bootstrap or Foundation. It covers linking the default stylesheet and using the `data-glyph` attribute for icon selection. ```html <link href="/open-iconic/font/css/open-iconic.css" rel="stylesheet"> <span class="oi" data-glyph="icon-name" title="icon name" aria-hidden="true"></span> ``` -------------------------------- ### Lazy Loader Service Implementation Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md The LazyLoader service is responsible for loading additional assemblies dynamically. It uses `LazyAssemblyLoader` to fetch DLLs and integrates with `NavigationManager` to trigger loading based on navigation events. It also handles potential exceptions during assembly loading. ```csharp using System.Reflection; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.Components.WebAssembly.Services; public class LazyLoader { public List<Assembly> AdditionalAssemblies { get; } private readonly LazyAssemblyLoader _lazyAssemblyLoader; private readonly NavigationManager _navigationManager; private readonly ILogger<LazyLoader> _logger; public LazyLoader( LazyAssemblyLoader lazyAssemblyLoader, NavigationManager navigationManager, ILogger<LazyLoader> logger) { this._lazyAssemblyLoader = lazyAssemblyLoader; this._navigationManager = navigationManager; this._logger = logger; } public async Task OnNavigateAsync(NavigationContext context) => await this.OnNavigateAsync(context.Path.Trim('/')); public async Task PreloadAsync() { var uri = new Uri(this._navigationManager.Uri); await this.OnNavigateAsync(uri.LocalPath.Trim('/')); } public async Task OnNavigateAsync(string path) { try { // πŸ‘‡ Load lazy assemblies that are needed for the current URL path. if (path == "counter") { var assemblies = await this._lazyAssemblyLoader .LoadAssembliesAsync(new[] { "CounterPage.dll" }); this.AdditionalAssemblies.AddRange(assemblies); } } catch (Exception ex) { this._logger.LogError(ex, "Error loading assemblies"); } } } ``` -------------------------------- ### Configure Prerendering Locale Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Specifies the culture or a comma-separated list of cultures for the prerendering process using the 'BlazorWasmPrerenderingLocale' MSBuild property. This allows for prerendering content in different languages. ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <BlazorWasmPrerenderingLocale>ja-JP,en-US</BlazorWasmPrerenderingLocale> ... ``` ``` -------------------------------- ### Locale Property Command-line Warning Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/MSBUILD-PROPERTIES.md Illustrates the warning regarding comma replacement for locale values when using the dotnet command line. ```shell > **Warning** > If you want to specify a comma-separated value as a property value, you must replace `,` (comma) with `%2c`. > ex.) `dotnet publish -c:Release -p:BlazorWasmPrerenderingLocale=ja%2cen` ``` -------------------------------- ### Customize Blazor WASM Prerendering Environment Name Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Allows customization of the hosting environment name during Blazor WebAssembly prerendering by setting the 'BlazorWasmPrerenderingEnvironment' MSBuild property in the .csproj file or via a dotnet publish command-line argument. ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <!-- ↓ If you want to make the environment name is "Production" even while pre-rendering, set the MSBuild property like this. --> <BlazorWasmPrerenderingEnvironment>Production</BlazorWasmPrerenderingEnvironment> ... ``` -------------------------------- ### Open Iconic with Bootstrap Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmLazyLoading/BlazorWasmApp/wwwroot/css/open-iconic/README.md Shows how to integrate Open Iconic with Bootstrap using the provided stylesheet. It includes instructions for linking the Bootstrap stylesheet and using the icon classes within `<span>` elements. ```html <link href="/open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet"> <span class="oi oi-icon-name" title="icon name" aria-hidden="true"></span> ``` -------------------------------- ### Using Open Iconic SVGs Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp1/wwwroot/css/open-iconic/README.md Demonstrates how to use individual SVG files from Open Iconic as standard image elements. Ensure to include an 'alt' attribute for accessibility. ```html <img src="/open-iconic/svg/icon-name.svg" alt="icon name"> ``` -------------------------------- ### BlazorWasmPrerendering.Build Version History Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt This section details the version history of the BlazorWasmPrerendering.Build package, highlighting key changes, fixes, and improvements introduced in each release. It covers support for different .NET versions, rendering modes, and specific bug resolutions. ```csharp v.6.0.0 - Fix: Anchor elements were incorrectly ignored even when they had a target attribute. - Fix: It crashed when a URL path included invalid characters for file systems. v.5.0.1 - Fix: It didn't work correctly when the .NET SDK version is 10. v.5.0.0 - .NET 9 support v.4.0.1 - Improve: Make it work correctly even when used with "BlazorWasmBrotliLoader.Build" NuGet package. v.4.0.0 - This is the first official - not a preview - release. - Breaking Change: Drop the support for .NET 5. - Fix: a service worker asset file was broken in some cases. v.3.1.0-preview.4 - Fix: the helper script crashed when it ran in a web worker. v.3.1.0-preview.3 - Fix: Pre-rendered apps with the "WebAssemblyPrerendered" render mode could not be run since v.3.1.0-preview.1. v.3.1.0-preview.2 - Fix: The publishing process on Visual Studio IDE was failed. v.3.1.0-preview.1 - Fix: Google Crawler could not recognize the pre-rendered header elements. (Issue #26) - Improve: Enabling the "data:" script source is no longer required when specifying a Content Security Policy (CSP). v.3.0.0-preview.2 - Update README: Add the instructions to avoid flicker with Lazy Assembly Loading - Add support for .NET 8 Preview 6 v.3.0.0-preview.1 - Improve: Add support for .NET 8 Preview 5 (WebCIL format enabled build is now supported). v.2.0.0-preview.9 - Improve: Detect appropriate dotnet CLI path - Add support for .NET 8 Preview 4 v.2.0.0-preview.8 - Add support for .NET 8 v.2.0.0-preview.7 - Improve: Add support for lazy loading assemblies. v.2.0.0-preview.6 - Improve: Add support for the latest version of the "Blazor Wasm Antivirus Protection". - Change the strategy of getting the "xorKey" to reading the "avp-settings.json" file. v.2.0.0-preview.5 - Improve: the pre-rendering server emulates the "/.auth/me" endpoint that is a part of Azure App Services Auth. v.2.0.0-preview.4 - Improve: Add support for the "Blazor Wasm Antivirus Protection". v.2.0.0-preview.3.1 Fix: Add support for an URL parameter, included dot. Fix: Could not serve static files that its name starting with a dot. v.2.0.0-preview.2 - Improve: Add support for setting the custom locale for crawling. v.2.0.0-preview.1 - Improve: Detached the pre-render web host to a separate out process. v.1.0.0-preview.28.0 - Improve: Determine the pre-rendering server's listening TCP port dynamically. v.1.0.0-preview.27.0 - Improve: Show the guide messages about how to fix the code when server errors happen. v.1.0.0-preview.26.0 - Fix: the same path, only the fragment was different, was repeatedly staticized. v.1.0.0-preview.25.1 - Fix: revert that the dropping support for .NET 7. v.1.0.0-preview.25.0 - Fix: PWA support - staticalized files are not reflected in a `service-worker-assets.js`. - BREAKING CHANGE: drop supporting .NET 7 temporarily because the .NET 7 SDK preview can not package multi-targeting frameworks Razor class library. v.1.0.0-preview.24.1 - Fix: fix typo in the README document. v.1.0.0-preview.24.0 - Improve: specify middleware packages to be installed by "AssemblyMetadata" attributes. v.1.0.0-preview.23.0 - Improve: add support for the "WebAssemblyPrerendered" render mode. v.1.0.0-preview.22.0 - Fix: crawl a "mailto:" protocol link and returns the result as a failure. - Improve: clarify classification of the crawling result (information/warnings/errors) v.1.0.0-preview.21.0 - Fix: the exit code of the "dotnet publish" command was 0 even when prerendering process encountered errors. v.1.0.0-preview.20.0 - Improve: add the "BlazorWasmPrerenderingDeleteLoadingContents" option for deleting "Loading...." contents from pre-rendered HTML and making pre-rendered contents are visible immediately even Blazor Wasm runtime has not been started. - Improve: show the message explaining how to keep running the pre-rendering server process for debugging when the crawler encountered whatever errors. - Improve: just skip "javascript:" links instead of reporting them as errors. v.1.0.0-preview.19.0 - Improve: allows specifying an URL path list that are not linked from anywhere for explicit fetching. v.1.0.0-preview.18.0 - Added the "BlazorWasmPrerenderingKeepServer" MSBuild property for troubleshooting. - Improve: show the server response when the HTTP status code does not represent success. - Improve: just skip instead of a crash even if a URL to fetch next was not a valid format. v.1.0.0-preview.17.0 - Fix: "PageTitle" and "HeadContnet" were not rendered on .NET 7. - Fix: Prerendering was failed if the target project references minor upgraded ASP.NET Core NuGet packages. v.1.0.0-preview.16.0 - Add support for .NET 7 v.1.0.0-preview.15.0 - Fix: "HeadContent" rendered twice when Blazor runs v.1.0.0-preview.14.0 - Imporve: added "OutputStyle" option ("IndexHtmlInSubFolders" style is default, and "AppendHtmlExtension" style can be chosen). v.1.0.0-preview.13.0 - Imporve: provides "IWebAssemblyHostEnvironment" during the prerendering process. ``` -------------------------------- ### BlazorWasmApp1 Loading Indicator Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/BlazorWasmPreRendering.Build.Test/_Fixtures/Assets/index.html Displays a loading message for the Blazor WebAssembly application. This is a common UI pattern during initial load or data fetching. ```html Loading... An unhandled error has occurred. Reload πŸ—™ ``` -------------------------------- ### BlazorWasmApp1 Loading Indicator Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp1/wwwroot/index.html Displays a loading message for the Blazor WebAssembly application. This is a common UI pattern during initial load or data fetching. ```html Loading... An unhandled error has occurred. Reload πŸ—™ ``` -------------------------------- ### Blazor WASM Prerendering: Target Framework Moniker Support Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt Improves the support for various target framework monikers (TFMs), making the prerendering solution more flexible and compatible with different .NET project configurations. ```csharp // Version: v.1.0.0-preview.6 // Change: Improved support for various target framework monikers. ``` -------------------------------- ### Using Open Iconic SVGs Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmLazyLoading/BlazorWasmApp/wwwroot/css/open-iconic/README.md Demonstrates how to use individual SVG files from Open Iconic as images. This method involves referencing the SVG file directly in an `<img>` tag and includes an `alt` attribute for accessibility. ```html <img src="/open-iconic/svg/icon-name.svg" alt="icon name"> ``` -------------------------------- ### Configure Blazor WASM Prerendering Output Style Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Controls the naming convention for staticalized output HTML files during Blazor WebAssembly prerendering. By default, files are named 'index.html' and placed in hierarchical subfolders. Setting 'BlazorWasmPrerenderingOutputStyle' to 'AppendHtmlExtension' appends '.html' to each request URL path. ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <!-- ↓ If you set this, then outut HTML files are named with each request URL path appended ".html" file extension. (ex. "http://host/foo/bar" β‡’ "./foo/bar.html")--> <BlazorWasmPrerenderingOutputStyle>AppendHtmlExtension</BlazorWasmPrerenderingOutputStyle> ... ``` -------------------------------- ### Blazor WASM Prerendering: Static Pre-rendering of .NET 6 Components Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt Enhances the prerendering capabilities by statically pre-rendering the .NET 6 'PageTitle' and 'HeadContent' components. This improves initial page load performance and SEO. ```csharp // Version: v.1.0.0-preview.8 // Change: Improve: The .NET6 "PageTitle" and "HeadContnet" components are also pre-rendered statically. ``` -------------------------------- ### Configure Blazor WASM Root Component Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Specifies the root component type and selector for Blazor WebAssembly prerendering. This is done by setting MSBuild properties in the .csproj file. The root component type can include the assembly name if it's not in the application assembly. ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <BlazorWasmPrerenderingRootComponentType>My.Custom.RootComponentClass</BlazorWasmPrerenderingRootComponentType> <BlazorWasmPrerenderingRootComponentSelector>.selector-for-root</BlazorWasmPrerenderingRootComponentSelector> </PropertyGroup> ... ``` ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <BlazorWasmPrerenderingRootComponentType>My.Custom.RootComponentClass, My.CustomAssembly</BlazorWasmPrerenderingRootComponentType> ... ``` -------------------------------- ### Blazor WASM Prerendering: C# 9 Top-Level Statement Support Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt Adds support for C# 9's top-level statement style in the implementation. This allows for more concise application entry points. ```csharp // Version: v.1.0.0-preview.7 // Change: Add support to the implementation that is C# 9 top-level statement style. ``` -------------------------------- ### Blazor WASM Prerendering: PWA Support Improvement Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt This update focuses on enhancing Progressive Web Application (PWA) support within the Blazor WebAssembly prerendering framework. No specific code is provided, but the change indicates improvements to how PWAs are handled. ```csharp // Version: v.1.0.0-preview.12.0 // Change: Improve PWA support. ``` -------------------------------- ### Blazor WASM Prerendering: Fix Publishing Crash Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt Addresses a critical issue where the prerendering process would crash during the publishing execution in Visual Studio. This fix ensures a smoother publishing experience. ```csharp // Version: v.1.0.0-preview.10.1 // Change: Fix: the pre-rendering process crashed at executing publishing on Visual Studio. ``` -------------------------------- ### Blazor WASM Prerendering: Root Component Selector and Type Specification Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/RELEASE-NOTES.txt Enhances the root component detection logic. The default selector now finds both '<div id="app">...</div>' and '<app>...</app>'. Additionally, the root component type specification can now include an assembly name, and the system will search all assemblies if the specified type is not found. ```csharp // Version: v.1.0.0-preview.5 // Changes: // - The default root component selector will find both "<div id='app'>...</div>" and "<app>...</app>". // - The root component type specification can include an assembly name. // - Find root component type from all assemblies if the specified type is not found. ``` -------------------------------- ### Configure WebAssemblyPrerendered Render Mode Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Sets the Blazor WASM prerendering mode to 'WebAssemblyPrerendered' using an MSBuild property. This mode affects how root components are registered and can improve perceived launch speed. ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <BlazorWasmPrerenderingMode>WebAssemblyPrerendered</BlazorWasmPrerenderingMode> ... ``` ``` -------------------------------- ### Adjust Blazor WASM Startup for WebAssemblyPrerendered Mode Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Modifies the Blazor WebAssembly application's startup code to conditionally register root components only if they haven't been registered via prerendered HTML content. This is necessary when using the 'WebAssemblyPrerendered' render mode. ```csharp var builder = WebAssemblyHostBuilder.CreateDefault(args); // πŸ‘‡ Add the condition that determine root components are // already registered via prerednered HTML contents. if (!builder.RootComponents.Any()) { builder.RootComponents.Add<App>("#app"); builder.RootComponents.Add<HeadOutlet>("head::after"); } ``` -------------------------------- ### Using Open Iconic SVG Sprite Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp1/wwwroot/css/open-iconic/README.md Illustrates the usage of Open Iconic's SVG sprite for efficient icon display. It shows how to reference icons using xlink:href and apply custom styling via CSS classes for size and color. ```html <svg class="icon"> <use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use> </svg> ``` ```css .icon { width: 16px; height: 16px; } .icon-account-login { fill: #f00; } ``` -------------------------------- ### Standalone Open Iconic Font Usage Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp1/wwwroot/css/open-iconic/README.md Explains how to use Open Iconic's icon font independently without a framework. Includes linking the default stylesheet and applying icons using the 'oi' class and 'data-glyph' attribute. ```html <link href="/open-iconic/font/css/open-iconic.css" rel="stylesheet"> <span class="oi" data-glyph="icon-name" title="icon name" aria-hidden="true"></span> ``` -------------------------------- ### Delete 'Loading...' Content Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md Set the `BlazorWasmPrerenderingDeleteLoadingContents` MSBuild property to `true` to remove 'Loading...' content from prerendered static HTML files. This makes prerendered content visible immediately upon page load, before the Blazor WebAssembly runtime is fully initialized. ```xml <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> ... <PropertyGroup> <!-- πŸ‘‡ If you set this MSBuild property to true, then outut HTML files do not contain the "Loading..." contents, and prerendered contents will be visible immediately. --> <BlazorWasmPrerenderingDeleteLoadingContents>true</BlazorWasmPrerenderingDeleteLoadingContents> ... ``` -------------------------------- ### Integrating LazyLoader with Blazor Router Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/README.md This HTML snippet shows how to inject the `LazyLoader` service into the `App.razor` component and configure the `Router` component to use the `AdditionalAssemblies` and `OnNavigateAsync` properties from the `LazyLoader` service. This allows the router to be aware of and utilize the lazily loaded assemblies. ```html @* Inject the "LazyLoader" service into the "App" component. *@ @inject LazyLoader LazyLoader @* Assign the "AdditionalAssemblies" and "OnNavigateAsync" properties of the "LazyLoading" service to the parameters of the "Router" component with the same name. *@ <Router AppAssembly=@typeof(App).Assembly AdditionalAssemblies=@LazyLoader.AdditionalAssemblies OnNavigateAsync=@LazyLoader.OnNavigateAsync> <Found Context="routeData"> <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> </Found> <NotFound> <PageTitle>Not found</PageTitle> <LayoutView Layout="@typeof(MainLayout)"> <p role="alert">Sorry, there's nothing at this address.</p> </LayoutView> </NotFound> </Router> ``` -------------------------------- ### Register Service Worker Source: https://github.com/jsakamoto/blazorwasmprerendering.build/blob/master/SampleApps/BlazorWasmApp0/wwwroot/index.html Registers the service worker for the application, enabling features like offline support and background updates. ```javascript navigator.serviceWorker.register('service-worker.js'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.