-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
This might be the same/related to Issue #51584.
I'm having issues refactoring an application going from Blazor server to the new SSR + InteractiveAuto mode.
I have a main page where i fetch all the data from my backend in the OnAfterRender if its firstRender.
This page then has a button that navigates to the same page but with different parameters. All of this works.
However on Blazor server the state of the component was kept and only re-rendered with new parameters.
Counter Component
@page "/counter/{Count:int?}"
<PageTitle>Counter</PageTitle>
@if(Count is not null)
{
<ComponentDetails Count="@Count" />
}
else
{
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
<button @onclick=@(() => NavigationManager.NavigateTo($"/counter/{currentCount}"))>SubPage</button>
}
@code {
[Parameter] public int? Count { get; set; }
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
protected override void OnAfterRender(bool firstRender)
{
if(firstRender)
{
Console.WriteLine("Backend called!");
}
}
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}ComponentDetails
@rendermode InteractiveAuto
<h3>ComponentDetails</h3>
<p>@Count</p>
@code {
[Parameter] public int? Count { get; set; }
}In the new Dotnet 8 Rendering mode the Component is "thrown away" and a whole new component is rendered which then has to fetch data from the backend all over again.
This might not be a bug but I've been unable to find a way to handle this. The docs mention something interesting but I haven't been able to find how such a thing would work.
Enhanced navigation and form handling
"If enhanced navigation is available for interactive client routing, navigation always goes through the interactive client-side router. This point is only relevant in an uncommon scenario where an interactive is nested inside a server-side rendered . In that case, the interactive router takes priority when handling navigation, so enhanced navigation isn't used for navigation because it's a server-side routing feature."
Expected Behavior
The navigation should not fetch a new page and should just re-render the current component with new parameters.
.NET Version
Dotnet 8

