-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Component will be prerendered (executed) in server with InteractiveWebAssembly settings. #51342
Comments
Some things are bit confusing at first indeed. Feel free to watch: https://www.youtube.com/@kis.stupid |
The prerenderer always runs on the Server. This may means you will need to add your "Service" for DepndecyInjection in the .Client for WebAssembly and in The Server for prerender. You could disable prerender like this if you don't want it (then it will only run in Browser):
|
PS works for all Render modes:
|
Using pre-render mode can enhance the responsiveness of your site, so it might be beneficial to incorporate it. This also simplifies the process if there's a need to support InteractiveServer. PS: you don't need to use generic types; this is since my component has a @typeparam T
|
Thank you for suggestion, all. I understand the workaround and prerendering is working on the server-side only. So the discussion points are below. Note: This problem will be problematic only when in the mixed application (blazor server and blazor wasm in single application). #1. Default prerendering mode should be always true in every application? #2. Component with InteractiveWebAssembly mode should be run in client-side? So I want to recommend that the default prerendering mode should be disabled, or @rendermode without prerendering option should be prepared by built-in. |
The primary concern with disabling prerendering is that the page can appear unresponsive, especially if the dotnetWasm isn't cached and is being downloaded for the first time. With slow internet connectivity, this might result in users seeing a blank screen for several seconds after clicking a menu link. While this might be acceptable for an internal company dashboard, it's problematic for public-facing sites. Visitors might perceive the site as malfunctioning and either leave or continuously refresh the page. As a result, potential customers could be lost simply due to the absence of prerendering. Therefore, enabling it by default is advisable. |
@nakamacchi thanks for contacting us. As several folks point out, the default approach is to prerender. This is not something that we currently plan to change. |
Is there an existing issue for this?
Describe the bug
[Symptoms]
When InteractiveWebAssembly is specified in the razor component created on the Client Project side, the initial processing is executed on the server side.
[Problems caused by this]
If HttpClient is @Inject on the WASM razor component, runtime will try to inject the server-side HttpClient on the first operation. An exception occurs when HttpClient is registered only on the WASM Client project side.
This behavior is reasonable if we use InteractiveAuto, but I suspect this is a bug when using InteractiveWebAssembly. (Maybe it is by-design, but it is very confusing.)
Expected Behavior
[Expected behavior]
When InteractiveWebAssembly is specified in the razor component created on the Client Project side, all processing is executed on the browser side.
Steps To Reproduce
No response
Exceptions (if any)
[Workaround]
It can be avoided by disabling prerendering by specifying below. However, the settings are very roundabout.
@rendermode InteractiveWebAssemblyWithoutPrerendering
@code {
static IComponentRenderMode InteractiveWebAssemblyWithoutPrerendering = new InteractiveWebAssemblyRenderMode(prerender: false);
}
or
@Attribute [RenderModeInteractiveWebAssembly(prerender: false)]
(I've heard that this is not deprecated in GA.
[Suggestion]
.NET Version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: