Skip to content

Blazor Activity links on global render vs per-page rendermode are totally different #64554

Description

@davhdavh

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

On project with per-page rendermode, the traces are pretty useless.

Microsoft.AspNetCore.Components.Navigate adds links to the route and then stores it in the link store.

_componentsActivityLinkStore!.SetActivityContext(ComponentsActivityLinkStore.Route, activity.Context,

However, when an event handler is run, that is in circuit context, which has a DIFFERENT _componentsActivityLinkStore and thus the links it was supposed to add does not exist.

Expected Behavior

On <Routes @rendermode="InteractiveServer" />
Image
and link to page activity in the event activity:

Image

Steps To Reproduce

  1. make new blank blazor with aspire and global rendermode.
  2. Start project
  3. Click Counter link
  4. Click Increment a few times
  5. Find trace in aspire -> CORRECT
  6. convert app to per-page (or just create another with per-page rendermode)
    a. remove global rendermode
    b. add rendermode to home and counter page
  7. do 2-5 again -> INCORRECT

Exceptions (if any)

On page level @rendermode

Image Image

.NET Version

10.0.100

Anything else?

No response

Activity

  1. added
    area-blazor
    on Nov 28, 2025
  2. added this to the .NET 11 Planning milestone on Dec 1, 2025
  3. javiercn commented on Aug 18, 2026

    @javiercn
    Member

    .NET 12 investigation findings

    The issue has been moved to .NET 12 Planning. This comment captures the investigation and prototype so the context is retained.

    Verdict

    The global/per-page difference is a bug, not an intentional telemetry-shape difference.

    The documented intent is that Microsoft.AspNetCore.Components.HandleEvent links to the current Navigate activity, and to the circuit activity for Interactive Server. Global interactivity already produces that shape. Per-page interactivity loses the route link because SSR routing and interactive event dispatch use different renderers and renderer-local link stores.

    Root cause

    • Global interactivity: Router, Navigate, and HandleEvent run on the same interactive renderer. They share one ComponentsActivityLinkStore.
    • Per-page interactivity: static SSR runs Router/Navigate on EndpointHtmlRenderer. The interactive component later runs on RemoteRenderer or WebAssemblyRenderer, each with a different link store.
    • The SSR route ActivityContext isn't transferred to the interactive renderer.
    • Enhanced navigation repeats the same problem when an existing interactive root receives updated SSR state.
    • An interactive subtree may contain no interactive Router, so the interactive runtime can't reconstruct the current route independently.

    Desired normalized telemetry

    For both global and per-page interactivity:

    1. SSR or interactive routing emits Microsoft.AspNetCore.Components.Navigate.
    2. Microsoft.AspNetCore.Components.HandleEvent contains the current aspnetcore.components.route tag.
    3. HandleEvent links to the current Navigate activity.
    4. Interactive Server additionally links to Microsoft.AspNetCore.Components.Server.Circuits.StartCircuit and carries the matching circuit ID.
    5. Interactive WebAssembly has the same route/event shape without a circuit activity.

    Prototype architecture

    The draft PR contains a prototype based on a framework-owned persistent service:

    • A renderer-associated activity-state owner captures/applies the current route context.
    • Separate persistent wrapper services target native Server and WebAssembly render modes and delegate to that owner.
    • Initial persistent-state restoration handles runtime/circuit initialization.
    • AllowUpdates = true handles enhanced-navigation state updates.
    • An explicit null route update clears stale route state.
    • Server ownership remains scoped. The browser owner is singleton because the WASM host and renderer can resolve through different scopes.
    • Interactive Auto persists to both Server and WebAssembly destinations.
    • The implementation is internal and adds no public API, InternalsVisibleTo, or new cross-assembly accessor.

    E2E test design

    The prototype exercises only per-page interactivity, not global interactivity:

    Runtime Initial activation Enhanced navigation
    Interactive Server Covered Covered
    Interactive WebAssembly Covered Covered

    The enhanced-navigation scenario keeps the same interactive root instance in a static layout and intentionally has no interactive Router. This proves that persistent-state updates, rather than interactive routing, refresh the route context.

    Telemetry is tested as a black-box stream:

    • Server activities are captured by an in-memory OpenTelemetry exporter.
    • WASM activities are captured by an OpenTelemetry exporter and posted to the test server.
    • A collector correlates spans by test ID and exposes them from a JSON endpoint.
    • The E2E test drives the page, retrieves the JSON stream, and asserts operation order, route tags, route links, and Server circuit links/IDs.

    Validation completed

    • Focused activity source/state tests passed: 13
    • Cross-runtime E2E telemetry matrix passed: 4
      • Server initialization
      • WebAssembly initialization
      • Server enhanced navigation
      • WebAssembly enhanced navigation

    The prototype commits are preserved on draft PR #68539:

    • 7b47c46e0f — initial persistent-state transfer prototype
    • 5bb1ae99fa — persistent service redesign and first E2E coverage
    • c374ec9c68 — cross-runtime telemetry test foundation

    .NET 12 follow-up decisions

    • Finalize the internal persistent-service registration shape and lifetimes.
    • Decide whether exact duplicate Navigate activities produced by SSR/request rendering are expected or should be normalized separately.
    • Keep the public telemetry shape equivalent between global and per-page interactivity.
    • Retain end-to-end assertions against exported telemetry rather than component-internal probes.
    • Rebase/rework the draft PR when .NET 12 implementation work resumes.
  4. added theissue type on Oct 16, 2026
  5. added
    bug
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-blazorbuginvestigate

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions