Closed captainsafia closed 4 years ago
@captainsafia ... is your sample app in an accessible repo? I ran into a different problem working the docs issue, and I was wondering if I could see your test app to see if I can get my console error sorted out because it sounds like you took a different approach implementing @danroth27's guidance.
This is actually an issue that a user reported in another repro that I migrated here for triage.
@daemogar Can you share the repro for this?
@daemogar ... I also walked that guidance, so you might want to check my docs PR to compare notes. I have the two scenarios working (hosted WASM and components in pages/views), but I have a pesky console error that I can't figure out. I didn't hit the problem that you're reporting here.
@guardrex I have a SampleHostedApplication with all the things I have done that replicate the issue I have. This can be run in VS Code for the same issue.
Thanks @daemogar ... I'll try to look at that tomorrow (Friday) to compare notes. I think it's good that you hit a different error than I did. It might be that I'm close to getting the basic doc coverage figured out. I'll post back when I have more info either way. Thanks again!
Looks like the only thing that you did different is:
<div>
with an id
of app
. Pages
.index.html
in the client app ... I delete the file.I gave it a shot and ended up with a 3rd (new) error ...
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: s.parentNode is null s@http://localhost:5000/_framework/blazor.webassembly.js:1:8888 ...
Also, the whole app failed. My approach (described on the PR) leaves the app working ... but perhaps in an unstable state ... just throwing a console error.
My console error is ...
Microsoft.JSInterop.JSException: Could not find any element matching selector '#app'. blazor.webassembly.js:1:14673
:tada: Ah, ha! :tada: ... I just got rid of that console error by deleting ...
builder.RootComponents.Add<App>("#app");
... from the client app's Program.Main
. I think I'm good over there for review, but I have little confidence until Javier or Safia has a look. In spite of a working app now, I might be doing it wrong. It's just a collection of 🙈 RexHacks!:tm: 🙈 at this point.
So as it turns out, yours and my issues were actually related. With the new WebAssemblyPrerendered render mode, you no longer need the builder.RootComponents.Add<App>("#app");
in your WASM app. So I removed that line and it worked like a charm. The index.html file and the need for the <div>
were not necessary, so I removed both. I have updated my sample code for clarification. Thanks for the help, and we can close this issue.
Thanks @daemogar ... I'm glad to hear that. It gives me a bit more confidence in that docs PR. I'll wait for Javier to get back and review for final touches.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.
@guardrex pre-rendering gets a lot more involved and complicated when you are beyond a Hello World app. E.g. if you have authentication in your Blazor WASM client and want to do pre-rendering, you get this:
InvalidOperationException: Cannot provide a value for property 'AuthenticationStateProvider' on type 'Microsoft.AspNetCore.Components.Authorization.CascadingAuthenticationState'. There is no registered service of type 'Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider'.
Microsoft.AspNetCore.Components.ComponentFactory+<>c__DisplayClass6_0.<CreateInitializer>g__Initialize|2(IServiceProvider serviceProvider, IComponent component)
I haven't worked the WASM auth topic set for [RC1] Microsoft Identity Platform 2.0 for Blazor (dotnet/AspNetCore.Docs #19503) yet. That work is imminent ... starting today/tomorrow or early next week. I'm just waiting on getting a couple of open PRs merged before starting, then I might just hit what you're seeing there. Thus far, the only thing I've worked out for myself (and for the Integrate components updates (dotnet/AspNetCore.Docs #19887)) PR is the base case without auth.
Since that's :point_up: a new error as far as this issue is concerned ... and if you searched this repo and didn't see an issue for that error ... open a new issue for it on this repo so that the product unit can focus in on it. Please add a cc: @guardrex
to your opening comment.
@ChristianWeyer In my WASM part of the app, I have to create a class that implements the AuthenticationStateProvider and then add it to be Dependency Injected. Not sure if that helps.
@captainsafia You can close this ticket as resolved. I do not have an option to close it as I am not the originator.
When using the WebAssemblyPrerendered in a _Host page for rendering a Blazor app, Renders as expected on the server, but fails with the below error when trying to activate the WebAssembly client-side. I have tried using the ServerPrerendered and it fails even on the server now, and this app was working before the update to .NET 5 RC1. I following the instructions at the link (Blog Posted on gitter.im by @danroth27) below for Upgrade an existing project and Blazor WebAssembly prerendering.
So I started a new project and only made the minimum necessary changes to do a WebAssemblyPrerendered project that is a DotNetCore Hosted server with the _Host page.
I get the same error in either both my existing project or the new project.
Blog Post by @danroth27 https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-5-release-candidate-1/
Originally posted by @daemogar in https://github.com/dotnet/core/issues/5200#issuecomment-693639454