Skip to main content

Blazor Render Modes Demo

The solution has a blazor web app template + a minimal API backend to demonstrate some new features.

Solution Structure

  • BlazorRenderModes: Main server project hosting the Blazor app and APIs.
  • BlazorRenderModes.Client: Blazor WebAssembly client project.
  • WeatherApi: Minimal API backend for weather data.

Running the Demo

  1. Open BlazorRenderModes.sln in Visual Studio or your preferred .NET IDE.
  2. Launch WeatherApi then BlazorRenderModes
  3. Explore the solution
  4. Faster static web assets
    • Program.cs uses app.MapStaticAssets()
      • better compression
      • fingerprinting for aggresive caching
    • Components/App.razor need to update the static assets path to use the magic @Assest[] thing
  5. Note how there is no caching in debug - lets test out the published app
  6. Publish the app in release mode dotnet publish -c Release
  7. Go to the published direcroty cd bin/Release/net9.0/publish
  8. Run and explore the published app dotnet BlazorRenderModes.dll The caching should be working, and assets should load fast.
  9. Counter - Try out all the different render modes:
    • Server - Server-side rendering
    • WebAssembly - Client-side rendering
    • Auto - A combination of both server and client rendering
  10. Server Mode - test reconnection handling
  11. Weather - Try add/remove streaming