Skip to main content

Build

Add Aspire to Blazor

.NETOfficialCertified

Add or complete .NET Aspire integration for an existing browser-hosted Blazor WebAssembly app or ASP.NET Core Blazor Web App. DO NOT USE FOR: .NET MAUI, Blazor Hybrid, BlazorWebView, or native-process telemetry, even if the request mentions Aspire or the Aspire dashboard. USE FOR: "add Aspire to my Blazor app", wiring a standalone WebAssembly gateway or a Blazor Web App into an AppHost, configuring service discovery and same-origin API proxying, or exporting OpenTelemetry from these web apps. Also exclude creating a new Blazor app (use create-blazor-project), general HTTP data loading (use fetch-and-send-data), non-Blazor apps, Azure/Kubernetes deployment, or AppHost databases/containers/messaging unrelated to the Blazor front end.

  • New
  • v1.0.0
  • Reviewed Dec 4
  • No reviews yet

Getting started

Full instructions

Install the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.

Instructions: SKILL.mdv1.0.0

Add .NET Aspire to a Blazor App

Connect an existing Blazor front end to backend services through Aspire service discovery and stream its telemetry — including browser telemetry from a WebAssembly client — to the Aspire dashboard.

Prerequisites

Require .NET 11.0 or later for the Blazor app and Aspire 17.0 or later. From the
solution directory, run dotnet --version and aspire --version. Inspect global.json,
the Blazor target frameworks, and the AppHost package versions. Check the version and
runtime required by the existing AppHost separately from the Blazor app's target.
Preserve working versions and package sources. If the project falls below the minimum,
report what must change and get agreement before upgrading.

Use --prerelease when selecting Aspire.Hosting.Blazor for the browser recipes.
If the project requires stable-only packages, skip that integration and
report which browser capabilities it blocks. Use stable Aspire packages for server-only
orchestration.

If the user asks for advice only, describe the applicable commands and edits without
executing them. Mark runtime checks as not run.

Workflow

Step 1 — Choose the Blazor path

Inspect the app's project file, startup code, and render modes. Keep the existing render mode.

If you find Do this
Microsoft.NET.Sdk.BlazorWebAssembly, wwwroot/index.html, and no server host Open standalone-gateway.md. Serve the client through a Blazor Gateway.
Microsoft.NET.Sdk.Web with AddRazorComponents().AddInteractiveWebAssemblyComponents() and MapRazorComponents<App>().AddInteractiveWebAssemblyRenderMode() Open hosted-webapp.md. Keep the existing server as the browser host and configure its YARP proxy.
A Blazor Web App that uses only static SSR or Interactive Server Configure the AppHost, server defaults, and server-side API discovery. Skip the browser steps. Do not add a .Client project or a gateway.

Resolve links relative to this SKILL.md. If a reference is missing, list references
once and report which instructions you could not verify.

Step 2 — Report capabilities and actions before editing

Write a Capabilities table with columns Status, Capability, and Finding. Use
✅ Present, ❌ Missing, — Not applicable, or ⚠️ Blocked. For each item
below, name the observed version, project, registration, or configuration that supports
the status. Do not mark runtime behavior as verified from source alone.

Capability Check
.NET and Aspire Record each detected version and whether it meets the minimum.
AppHost Report project-based or single-file, and whether it exists or is selected for creation. If it exists, check for DistributedApplication.CreateBuilder and its AppHost package or SDK.
Resource registration Check that the AppHost registers each relevant app, gateway, and managed API.
Blazor hosting Report the path selected in Step 1.
API dependencies List each as AppHost-managed or third-party. If the app calls no APIs, report none.
Server defaults Check each hosted server and owned API for AddServiceDefaults() before Build() and MapDefaultEndpoints() before Run(). Reuse an existing defaults library.
WebAssembly defaults Find the client service-defaults library, confirm the WASM project references it, and check startup for AddBlazorClientServiceDefaults(). Check that the library matches the hosting path in Step 1.
Browser hosting and configuration Check the standalone gateway, base path, and client configuration, or the hosted server's WithBrowserOptions wiring.
API discovery Check that the app references each managed API resource in the AppHost and the applicable HTTP clients use its resource name, not a literal backend host or port. If a hosted component runs on both server and browser, check that both register the same named or typed client.
Browser API proxy Check for a gateway reference on the standalone path or a mapped YARP route on the hosted path. Confirm the browser gets the proxy address through configuration.
Server telemetry Check exporter configuration for each applicable server resource.
Browser telemetry Check that the dashboard exposes an HTTP/protobuf OTLP receiver and that the browser gets a same-origin OTLP path. Do not count the server's exporter as browser telemetry.

Apply these rules before selecting actions:

  • If no APIs exist, mark API discovery and API proxying Not applicable. Keep the
    applicable hosting and telemetry steps. If only third-party APIs exist, preserve their
    URLs and access policies. Do not register them for Aspire discovery or proxy them by
    default. Configure discovery for AppHost-managed APIs even when there are no third-party APIs.
  • If the app does not run WebAssembly, mark browser-only capabilities Not applicable.
  • Under Actions, number only the changes needed for Missing items. Name each
    file relative to the solution root. For commands, name the working directory and
    show the resolved command. For Blocked items, name the prerequisite or decision
    instead of scheduling the blocked action. If no changes are needed, write Actions: none.

Replace each <<placeholder-name>> before running a command. Resolve path placeholders
relative to the stated working directory. Run the actions in order, then
verify the applicable capabilities in Step 5.

Step 3 — Add the AppHost and server defaults

Run the commands in this step from the solution root.

  1. If there is no AppHost, run dotnet new aspire-apphost -o "<<apphost-directory>>" for a project-based
    host or dotnet new aspire-apphost-singlefile -o "<<apphost-directory>>" for a file-based host. If a
    template is missing, run dotnet new install "Aspire.ProjectTemplates::<<aspire-version>>"
    with the matching template version. Keep an existing AppHost's format.

  2. If the hosted server or an owned API lacks server defaults, reuse the solution's
    defaults library. If none exists, run dotnet new aspire-servicedefaults -o "<<server-defaults-directory>>".
    Add a reference from each server project that needs it, substituting the actual paths:

    bash
    dotnet add "<<server-project-path>>" reference "<<server-defaults-project-path>>"
    

    Call builder.AddServiceDefaults() before Build() and app.MapDefaultEndpoints()
    before Run(). Do not reference server defaults from a WebAssembly project.

  3. Register missing hosted servers and owned APIs with AddDotnetProject, using paths
    relative to the AppHost. If the hosted server calls an owned API, add a reference
    from the server to the API resource:

    csharp
    var api = builder.AddDotnetProject("your-api", "../Api/Api.csproj");
    builder.AddDotnetProject("webapp", "../WebApp/WebApp.csproj").WithReference(api);
    

    Keep legacy Projects.* references used by other resources.

  4. Configure server HTTP clients that call an AppHost-managed API to use the API
    resource name. Use an https discovery URI for HTTPS-only or https+http if HTTP
    fallback is allowed. Keep working registrations and transport policy.

Step 4 — Add the missing WebAssembly wiring

  1. Skip this step if the app does not run WebAssembly or cannot use the Blazor hosting
    package. Otherwise, follow the shared client setup to
    generate or reuse client service defaults and wire them in the client's Program.cs.
    Register resource-named HTTP clients only for AppHost-managed APIs. Reuse the same
    registration on the hosted server if the component also calls the API there.
  2. Follow the reference selected in Step 1. For standalone, register the client with
    AddBlazorWasmApp, add WithReference(api) if it calls an AppHost-managed API,
    attach it to the gateway with WithBlazorClientApp, and match index.html's
    <base href> to the resource sub-path. For hosted, map the
    AppHost-generated proxy routes with YARP, and pass browser configuration using
    WithBrowserOptions. Keep proxy setup and configuration parsing in a separate
    helper file; call the helpers from Program.cs. For AppHost-managed APIs, route
    browser requests through the app origin and verify protected routes still enforce
    authorization.
  3. Check that the browser receives an OTLP path. If Aspire cannot resolve a dashboard
    HTTP/protobuf receiver, configure it in the active AppHost profile using
    dashboard endpoint troubleshooting.
    Do not send dashboard addresses or credentials to the browser.

Step 5 — Run the AppHost and verify each signal

From the AppHost directory, use the existing HTTPS profile and run:

bash
aspire run
  1. In a second terminal in the AppHost directory, run aspire describe --format Json.
    Check resource states and take the app or gateway HTTPS URL from the output. For
    standalone, check the gateway configuration
    before opening a browser.

  2. Open the app and trigger one interaction. Use the browser's Network panel or, if
    installed, playwright-cli in one named session:

    shell
    playwright-cli -s=blazor-validation open "<<app-url>>"
    playwright-cli -s=blazor-validation snapshot
    playwright-cli -s=blazor-validation requests
    

    Use goto for a deep link and click with an element reference from snapshot if
    needed. Confirm visible app content and inspect the statuses of framework assets,
    any applicable same-origin API request, and the browser's OTLP posts. Use the
    standalone or
    hosted checks for the exact paths.

  3. Use Aspire CLI to confirm dashboard ingestion for each applicable server or browser
    telemetry source. Use the actual source name, not the gateway name for browser telemetry:

    shell
    aspire otel logs "<<telemetry-source>>" --limit 5
    aspire otel spans "<<telemetry-source>>" --limit 5 --format Json
    

    If the app calls a managed API, take the trace ID from the relevant request span and
    run aspire otel spans --trace-id "<<trace-id>>" to check the app and API spans together.

  4. Keep the page open through one metric export interval if checking browser metrics.
    Aspire 17's CLI does not show metrics. To verify dashboard display, open Metrics
    in the dashboard and select the emitting resource. If you only observe a successful
    metrics POST, report export accepted; dashboard display not checked. Do not
    share the dashboard login token. Close the Playwright session if you opened it:
    playwright-cli -s=blazor-validation close.

Write a Verification table with columns Check, Status, and Evidence. Mark each
applicable check Passed, Failed, or Not run. Cite the observed result or
explain why the check could not run. Do not report browser telemetry as verified from
a successful build or server-only trace.

If a check fails, open troubleshooting.md and follow
the entry for the observed symptom.

Explore more skills

Browse all
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Signing

SignedSLSA L2
Signed by
skills-hub.ai distributor
Method
Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
Key
skills-hub-ed25519-2026-11
Signed

Reviews (0)

More from .NET

View source →
analyzing-dotnet-performanceScans .NET code for ~50 performance anti-patterns across async, memory, strings, collections, LINQ, regex, serialization, and I/O with tiered severity classification. Use when analyzing .NET code for optimization opportunities, reviewing…16 installscreate-skillScaffolds new agent skills for the dotnet/skills repository. Use when creating a new skill, generating SKILL.md files, writing a skill description that the runtime will actually route to, or setting up skill directory structures. Handles…10 installscsharp-scriptsRun file-based C# apps with the .NET CLI when the user explicitly wants C#/.NET code without creating a project. Use for C# language/API experiments, one-file C# apps, small multi-file C# apps composed with `#:include`/`#:exclude`, or C#…6 installscode-testing-extensionsProvides file paths to language-specific extension files for the code-testing pipeline. Read this reference-only catalog for extension guidance files (e.g., dotnet.md for .NET, cpp.md for C++). Agents and skills read its bundled files…4 installsmigrate-nullable-referencesEnable nullable reference types in a C# project and systematically resolve all warnings. USE FOR: adopting NRTs in existing codebases, file-by-file or project-wide migration, fixing CS8602/CS8618/CS86xx warnings, annotating APIs for…3 installscreate-blazor-projectCreate a new ASP.NET Core web application or web site using Blazor. USE FOR: creating a new Blazor web app, scaffolding a new web project, starting a new web site, choosing render modes (Static SSR, Interactive Server, Interactive…3 installs

Frequently asked questions about add-aspire-to-blazor

What does the add-aspire-to-blazor skill do?

Add or complete .NET Aspire integration for an existing browser-hosted Blazor WebAssembly app or ASP.NET Core Blazor Web App. DO NOT USE FOR: .NET MAUI, Blazor Hybrid, BlazorWebView, or native-process telemetry, even if the request mentions Aspire or the Aspire dashboard. USE FOR: "add Aspire to my Blazor app", wiring a standalone WebAssembly gateway or a Blazor Web App into an AppHost, configuring service discovery and same-origin API proxying, or exporting OpenTelemetry from these web apps. Also exclude creating a new Blazor app (use create-blazor-project), general HTTP data loading (use fetch-and-send-data), non-Blazor apps, Azure/Kubernetes deployment, or AppHost databases/containers/messaging unrelated to the Blazor front end. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the add-aspire-to-blazor skill?

Run `npx @skills-hub-ai/cli install dotnet-add-aspire-to-blazor` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/dotnet-add-aspire-to-blazor/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does add-aspire-to-blazor work with?

add-aspire-to-blazor runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the add-aspire-to-blazor skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use add-aspire-to-blazor after installing it?

In Claude Code, type `/dotnet-add-aspire-to-blazor` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the add-aspire-to-blazor skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/dotnet-add-aspire-to-blazor)](https://skills-hub.ai/skills/dotnet-add-aspire-to-blazor)
HTML
<a href="https://skills-hub.ai/skills/dotnet-add-aspire-to-blazor"><img src="https://skills-hub.ai/api/badges/skill/dotnet-add-aspire-to-blazor" alt="Install on Skills Hub"></a>

More options in the badge docs.