[Blazor] Aspire integration improvements
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
This issue tracks the work to integrate Blazor applications with Aspire, enabling Blazor apps to benefit from Aspire's orchestration, service discovery, telemetry, and configuration capabilities.
### Overview
The integration provides first-class support for all Blazor hosting models (WebAssembly, Server, and Blazor Web) within .NET Aspire applications, using a Backend-for-Frontend (BFF) pattern via a **Blazor Gateway** component.
### Key Features
**Blazor Gateway** provides:
- Optimized serving of WebAssembly static assets with `MapStaticAssets` (compression & caching)
- API proxying to backend services (eliminates CORS requirements)
- Configuration flow to WebAssembly clients via `/_blazor/_configuration`
- Session affinity for multi-replica Blazor Server scenarios
- Replacement for the Dev Server in both development and production
### Hosting Scenarios
| Scenario | Gateway Configuration |
|----------|----------------------|
| Standalone WebAssembly + Aspire | Separate node (defined in AppHost) |
| Hosted WebAssembly | Embedded in host project |
| Blazor Server (single replica) | Not required |
| Blazor Server (multi-replica) | Separate node (load balancing + session affinity) |
| Blazor Web (Server + WASM) | Embedded or separate (based on replica count) |
### Related Work Items
- [ ] Server-side configuration endpoint for Blazor Web (#30116)
- [ ] IHostedService support in WebAssembly (#63637)
- [ ] Environment variables in IConfiguration by default (#64576)
- [ ] Gateway package for standalone Blazor WebAssembly (#64573)
- [ ] WebAssembly service defaults template (#64574)
- [ ] Consider enabling MetricsSupport/EventSourceSupport by default (#64575)
- [ ] Register Components metric and tracing by default on webassembly host (#64736)
Contributor guide
Assessment
This issue has not been assessed yet.