microsoft / microsoft/aspire

Aspire.Hosting.Blazor: SPA catch-all route constraint "{**path:nonfile}" leaks into OpenTelemetry span names in the dashboard

Open
#17,693 1 comment 0 reactions 0 assignees View on GitHub
area-dashboard area-telemetry triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

## Summary

Traces from the Blazor gateway (added by `Aspire.Hosting.Blazor`) appear in the Aspire Dashboard with the span name `GET {**path:nonfile}` instead of a user-meaningful route. The raw `{**path:nonfile}` ASP.NET Core `MapStaticAssets` catch-all route constraint leaks directly into the OpenTelemetry span name, making traces hard to read.

## Observed behavior

In the Dashboard `/traces` page, WASM app requests through the Blazor gateway appear as:

```
blazor-gateway: GET {**path:nonfile}
```

Users expect to see something like:
```
blazor-gateway: GET /web-client/**
```
or at minimum:
```
blazor-gateway: GET /{**path}
```

## Root cause

In `src/Aspire.Hosting.Blazor/Scripts/PrefixEndpoints.cs`, the SPA catch-all fallback endpoint is registered with:

```csharp
fallback.Route = "{**path:nonfile}";
```

The `:nonfile` constraint is required by ASP.NET Core's `MapStaticAssets()` routing (it ensures the catch-all doesn't override static file routes), but when ASP.NET Core's OpenTelemetry HTTP server instrumentation records the `http.route` attribute, it uses the raw route template — including the `:nonfile` constraint. This becomes the span name in the dashboard.

## Expected behavior

The span name (and `http.route` attribute) for the SPA catch-all should not expose the internal `:nonfile` constraint. Options:

1. **Configure OTEL route formatting** in the Blazor gateway to strip route constraints from the span name, normalizing `{**path:nonfile}` → `{**path}`.
2. **Apply `[EndpointName]` or `WithName()`** to the catch-all endpoint with a human-readable name that OTel will use instead of the route template.
3. **Use `WithDisplayName()`** on the route group so the dashboard shows e.g. `GET /web-client (SPA fallback)`.

## Environment

- Aspire CLI 13.4.0 / `Aspire.Hosting.Blazor` 13.4.0
- Reproduced with a WASM app served under a path prefix (e.g. `/web-client`)
- Relevant file: `src/Aspire.Hosting.Blazor/Scripts/PrefixEndpoints.cs`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.