Skip to content

Blazor webassembly does not initialize components in the LayoutComponentBase after webassembly resources downloaded. #50585

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

Closed
1 task done
IvanDmitriev1 opened this issue Sep 8, 2023 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue investigate Status: Resolved
Milestone

Comments

@IvanDmitriev1
Copy link

IvanDmitriev1 commented Sep 8, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When blazor has downloaded all webassembly resources, it initializes, but also forgets to initialize components that have @rendermode="@RenderMode.Auto". This will not happen if the resources are already cached.

Expected Behavior

Blazor should initialize all component that have RenderModeAuto or @rendermode="@RenderMode.Auto".

Steps To Reproduce

I have create a repository for this issue: https://github.com/IvanDmitriev1/BlazorIssue

  1. Navigate to the index page
  2. Clear site cache (if it's not first loading)
  3. Reload page
  4. Navigate to the dialog page and click on Open Dialog button
  5. An error will occur because DialogProvider that is in MainLayout isn't initialized

Exceptions (if any)

No response

.NET Version

8.0.100-rc.2.23462.28

Anything else?

.NET SDK:
Version: 8.0.100-rc.2.23462.28
Commit: 5e71ffbd44

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100-rc.2.23462.28\

.NET workloads installed:
There are no installed workloads to display.

Host:
Version: 8.0.0-rc.2.23431.9
Architecture: x64
Commit: 3c48925a6c
RID: win-x64

.NET SDKs installed:
6.0.414 [C:\Program Files\dotnet\sdk]
7.0.401 [C:\Program Files\dotnet\sdk]
8.0.100-rc.2.23462.28 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0-rc.2.23455.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0-rc.2.23431.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0-rc.2.23454.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Sep 8, 2023
@mkArtakMSFT mkArtakMSFT added this to the 8.0-rc2 milestone Sep 11, 2023
@SteveSandersonMS
Copy link
Member

I think this is the same issue as described at #50686. That is, you have this in your layout:

<DialogProvider @rendermode="@RenderMode.Auto" />

... so it initially resolves as Server. Since it never gets removed from the page, it continues to use Server. Then when you later visit Dialog.razor (which also has RenderModeAuto), the rendermode for the page resolves as WebAssembly. Since there are different hosting platforms, they aren't sharing the same DI services, and hence it fails.

I'll close as a duplicate of #50686 but please let me know if you think that doesn't cover it.

@MackinnonBuck Looks like this is further reason to make Auto continue resolving as Server until all the server components are gone.

@SteveSandersonMS SteveSandersonMS closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
@danroth27 danroth27 added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Oct 4, 2023
@ghost ghost added the Status: Resolved label Oct 4, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue investigate Status: Resolved
Projects
None yet
Development

No branches or pull requests

5 participants