-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor Web App render mode interactive auto does not switch from interactive server to interactive wasm when navigating between pages #53799
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
Comments
@lokitech ... I think this is going to end up being by-design behavior. We've tried (and possibly failed 🙈) to address this situation at (second paragraph) ... ... focusing on ...
Mackinnion's remarks are here ... I'll work that text further based on additional discussion here with the engineers. One of things that I'd like to flesh out in this scenario is exactly when does the router switch over to CSR ... what has to happen to break out of interactive SSR when navigating around Interactive Auto components that have initially adopted interactive SSR. |
Hi hello there, thank you for your reply. I would just like to say that I'm a bit perplexed with this decision, consider the following scenario: Developer creates a Blazor Web App with render mode set to auto and interactivity location to global, meaning essentialy every page and compnent will have the render mode set to auto. First time users, will more than likely, be presented with server-side rendering while the WASM application downloads in the background, so their entirety of that first visit will be server-side rendered since:
and auto mode is global. What I have measured is that initial load with server-side rendering is faster regardless WASM is cached or not. It would be ideal if every visit to the page is server-side rendered and then switched to client-side rendering as user navigates thourgh the application. |
Hi @lokitech,
Please correct me if I'm wrong, but I think your argument can be summarized by saying that since navigating from one You're definitely right that there are cases where terminating the circuit and switching to WebAssembly interactivity is worthwhile, even if it means interactive state is lost. However, that's not always going to be the right choice, because the circuit might contain additional state that isn't strictly component state (DI services, etc.) that the app author wants to persist between navigations. You do bring up a good point that navigating to a non-interactive page terminates the circuit and loses interactive state anyway. We felt that it was worth it to dispose the circuit and its state if there aren't any interactive components around to immediately utilize that state, although I can appreciate that it's somewhat subjective to draw the line there. Perhaps #48756 would allow the configuration of some of this behavior, or we could consider another way to allow explicit configuration of what happens when:
If all these conditions are met, then we could consider terminating the circuit and allowing the |
Hello @MackinnonBuck As I've stated I understand the loss of component state along with DI services and everything in the application we are switching from. IMO that's even more of a reason to allow developers greater control over when the switch happens, so we (users-developers) can plan accordingly and tailor it for our use-cases. I appreciate your time investigating this and considiring it for upcoming releases. |
In addition, there is another problem. If we have a secure APi (cookies) hosted in the server application, when the client page (auto render) is rendered on the server (without switching to webassembly), it can no longer access that API, and it is necessary to return to another SSR page (where it closes the connection with SignalR) so that it renders as webassemply again and be able to access the API. |
Is there an existing issue for this?
Describe the bug
When using the default Blazor Web App template with interactivity set to auto and per page/component, first time visiting Counter page results in the page being rendered as InteractiveServer which is completely fine, after navigating to Home or to Weather page and then back to Counter, it is rendered in InteractiveWasm which is also great.
The problem occurs when I transfer the Weather page to Client project and set it to InteractiveAuto. After running the application and navigating to Counter or Weather page, the initial load happens in InteractiveServer which is also fine, but no matter how many times I navigate between Counter and Weather pages, it never makes a switch to InteractiveWasm as it does in the case when I navigate to Home and then back to Counter.
Expected Behavior
I would expect that after the WASM files are downloaded, the application would make a switch to InteractiveWasm when navigating between InteractiveAuto pages. As it does when I navigate from Counter to Home and back to Counter.
When navigating from Counter to Home a POST request is made to https://localhost/_blazor/disconnect with circuitId as payload which disconnects the WebSocket.


So when navigating back to the Counter page a GET request is made for blazor-hotreload.js which apparently switches the application from InteractiveServer to InteractiveWasm.
So as far I can see, the functionality is there, is there a way to force the switch to InteractiveWasm when navigating from one InteractiveAuto to another InteractiveAuto page after the WASM files are downloaded?
Steps To Reproduce
@rendermode InteractiveAuto
.<DisplayRenderMode />
to Home, Counter and Weather pages.Here is the minimalistic project which reproduces this issue: https://github.com/lokitech/Blazor-Web-App-Render-Modes-Bug
Exceptions (if any)
No response
.NET Version
8.0.1
Anything else?
No response
The text was updated successfully, but these errors were encountered: