Skip to content

StreamRendering on first page continue to render after navigation #50733

Closed
@mattyas

Description

@mattyas

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using @Attribute [StreamRendering(true)] on the landing page or one of its component, the page continue to refresh after navigating to a subpage, replacing the page or part of the page.

30df6324-6fd5-4e0b-922f-f355dd06e0c2.webm

Expected Behavior

  1. That the page you navigate to not blend with the page you left
  2. That it is possible to cancel an OnInitializedAsync with the help of a cancellation token when it is no longer rendered on the page, stopping the long running request or pollling. (A workaround for this except on the landing page is to listen to httpContext.RequestAborted)

Steps To Reproduce

Create new template:

change weather forcast delay to 5000ms

        // Simulate asynchronous loading to demonstrate streaming rendering
        await Task.Delay(5000);

and replace the home page with the following.

@page "/"
@attribute [StreamRendering(true)]
<PageTitle>Home</PageTitle>

<h1>Hello, world @Id!</h1>

Welcome to your new app.

@code {

    private int Id { get; set; }
    protected override async Task OnInitializedAsync()
    {
        for (Id = 0; Id < 10; Id++){
            await Task.Delay(1000);
            StateHasChanged();
        }
    }
}

Full sample can be found here

Exceptions (if any)

No response

.NET Version

8.0.100-rc.1.23455.8

Anything else?

No response

Metadata

Metadata

Labels

area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions