-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
.NET 8 RC1 Blazor Web App: [RenderModeAuto] keeps using the Server implementation then switches to WASM #50677
Comments
@dmm-l-mediehus thanks for contacting us. That's by design. At least for 8.0, handling the transition between server and webassembly is not trivial, so we require a page refresh (or the next visit) to avoid having to deal with complications derived from the page state. |
In best practice, then how should I implement this example of using RenderModeAuto and calls to DB? |
Components should rely on abstractions when interacting with services which may have client or server implementations. That way, no matter where they get rendered the environment-specific implementation will provide the right functionality. |
@mkArtakMSFT That's what I did, right? I have client and server implementations abstracted by an interface, and it calls the database twice which is a bug. I'm using Microsoft's documentation on stateful reconnection after prerendering by using IMemoryCache...But it still calls it twice since there's 2 different implementations and it calls them both. Having await Task.Delay(1000); for testing, it waits 2 seconds, and I expect it to be 1 second to load /weather |
This might be related to issue #50686 |
@ynnob Sounds like it. Just odd they said that's by design, and said what to do in practice to get it to work... and that's exactly what I am doing. |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
Is there an existing issue for this?
Describe the bug
I have a simple Weather app that consists of 3 projects:
Class Library holds interfaces, and service-implementations.
in Weather.razor (
BlazorApp1.Client.Components.Weather.razor
), I inject IWeatherService and use GetForecastsAsync()-method to get forecasts.I noticed the app keeps using Server implementation (WeatherService.cs) at first (both navigating from /counter back to weather and F5 refresh) then switches to WASM implementation (HttpClientWeatherService.cs), even though the app is finished downloaded in the background.
Expected Behavior
I expect the Web App to only use the WASM implementation of the service, when the application is downloaded and cached.
Steps To Reproduce
Exceptions (if any)
No response
.NET Version
8.0.100-rc.1.23455.8
Anything else?
No response
The text was updated successfully, but these errors were encountered: