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.
Getting started
Full instructionsInstall 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, writeActions: 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.
-
If there is no AppHost, run
dotnet new aspire-apphost -o "<<apphost-directory>>"for a project-based
host ordotnet new aspire-apphost-singlefile -o "<<apphost-directory>>"for a file-based host. If a
template is missing, rundotnet new install "Aspire.ProjectTemplates::<<aspire-version>>"
with the matching template version. Keep an existing AppHost's format. -
If the hosted server or an owned API lacks server defaults, reuse the solution's
defaults library. If none exists, rundotnet new aspire-servicedefaults -o "<<server-defaults-directory>>".
Add a reference from each server project that needs it, substituting the actual paths:bashdotnet add "<<server-project-path>>" reference "<<server-defaults-project-path>>"Call
builder.AddServiceDefaults()beforeBuild()andapp.MapDefaultEndpoints()
beforeRun(). Do not reference server defaults from a WebAssembly project. -
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:csharpvar api = builder.AddDotnetProject("your-api", "../Api/Api.csproj"); builder.AddDotnetProject("webapp", "../WebApp/WebApp.csproj").WithReference(api);Keep legacy
Projects.*references used by other resources. -
Configure server HTTP clients that call an AppHost-managed API to use the API
resource name. Use anhttpsdiscovery URI for HTTPS-only orhttps+httpif HTTP
fallback is allowed. Keep working registrations and transport policy.
Step 4 — Add the missing WebAssembly wiring
- 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'sProgram.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. - Follow the reference selected in Step 1. For standalone, register the client with
AddBlazorWasmApp, addWithReference(api)if it calls an AppHost-managed API,
attach it to the gateway withWithBlazorClientApp, and matchindex.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 fromProgram.cs. For AppHost-managed APIs, route
browser requests through the app origin and verify protected routes still enforce
authorization. - 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:
aspire run
-
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. -
Open the app and trigger one interaction. Use the browser's Network panel or, if
installed,playwright-cliin one named session:shellplaywright-cli -s=blazor-validation open "<<app-url>>" playwright-cli -s=blazor-validation snapshot playwright-cli -s=blazor-validation requestsUse
gotofor a deep link andclickwith an element reference fromsnapshotif
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. -
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:shellaspire otel logs "<<telemetry-source>>" --limit 5 aspire otel spans "<<telemetry-source>>" --limit 5 --format JsonIf the app calls a managed API, take the trace ID from the relevant request span and
runaspire otel spans --trace-id "<<trace-id>>"to check the app and API spans together. -
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- System Text JSON Net11Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming…
- Msbuild ServerGuide for using MSBuild Server to improve CLI build performance. Activate when developers report slow incremental…
- Build Perf BaselineEstablish MSBuild/.NET baselines before optimizing. USE FOR: unranked slow builds; cold/warm/incremental/no-op…
- Migrate Xunit to Xunit V3Migrate .NET test projects from xUnit.net v2 to xunit.v3 and fix v3 breaks. Use for package/CPM conversion,…
- microbenchmarkingActivate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing…
- Code Testing AgentLegacy compatibility alias for the code-testing skill. Do not self-activate for user requests and do not treat this…
Security
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 →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.
[](https://skills-hub.ai/skills/dotnet-add-aspire-to-blazor)<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.