-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NavigationManager.Refresh does not make use of optional parameter 'forceReload' #59854
Comments
The comment on that method is garbled too. |
@willdean thanks for contacting us. It seems that this is a bug. @MackinnonBuck was this intentional? |
This is intentional. Classes extending Since that method was added in .NET 8, and because it's a breaking change to introduce new abstract members to an existing class, we had to make the method Note that this method was added in the same release as static server rendering, meaning existing Also note that the XML docs indicate that /// If <paramref name="forceReload"/> is <c>true</c>, a full page reload will always be performed.
/// Otherwise, the response HTML may be merged with the document's existing HTML to preserve client-side state,
/// falling back on a full page reload if necessary. Meaning it's valid to always pretend the parameter is Hope this clarifies things! |
If there's a change to make here, it's probably a comment in the body of the // In the default implementation, we ignore the forceReload argument and always pass forceLoad: true.
// That way, this method doesn't no-op by default in implementations designed for fully interactive contexts. |
@Nico1395, could you clarify what you expected this to do, and how the actual behavior differs from that? I'm guessing this is a Blazor Server app created prior to .NET 8 but upgraded later? Or is it actually a Blazor Web App with server interactivity, created in the .NET 8+ timeframe? cc @javiercn - I see this was triaged as a bug and moved to the backlog, and I want to make sure there's visibility of the discussion. |
@MackinnonBuck Sorry for the late response, I was in my holidays. Well I would have expected the parameter to be used by default, so I could decide whether I prefer either a 'soft' refresh without a forced reload, or a 'hard' refresh with a forced reload. However while I do have the rare case where I would like to soft-refresh the page, I agree its not something you need often at all. You can also very easily work around it by |
No worries at all, @Nico1395.
Thanks for clarifying. I'm guessing by "soft" refresh you mean doing a re-render of the current page? If so, then yes, doing |
Also, If the page is static with an interactive island, and you call NavigateTo() with false, the InteractiveServer component will also not re-initialize, nor will the navigation happen |
Right, and that's expected when you pass the current URI to |
Yeah @MackinnonBuck , is the solution to add a @key property to the Interactive component on the static page so that it calls OnInitializedAsync in the interactive component again? TBH, I think passing current URI to NavigateTo() should 100% reload the page, and is currently a bug. All interactive components should be re-rendered, but not generate a new WS connection unless forceLoad = true is passed. |
Meaning re-initialized (they get Yeah, using a But, maybe that discussion should continue in #56961, since this issue tracks something else 🙂 |
Is there an existing issue for this?
Describe the bug
Hey!
I wanted to use
NavigationManager.Refresh(forceReload: false)
on our .NET8 Blazor Server app and noticed thatforceReload
is not being passed through toNavigateTo
, instead theforceReload
ofNavigateTo
defaults totrue
. You can easily see what I mean in this file in line 178:aspnetcore/src/Components/Components/src/NavigationManager.cs
Line 178 in 8d6d208
Expected Behavior
I assume this is not intentional as I cannot come up with a reason why it would be. If the parameter exists one would expect it to be used, right?
Steps To Reproduce
The code is obvious, but
NavigationManager.Refresh(forceReload: false)
reproduces the issue.Exceptions (if any)
None
.NET Version
8.0.x
Anything else?
I think the issue speaks for itsself.
The text was updated successfully, but these errors were encountered: