question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fix: v3 Library with Blazor Web App .NET 8

See original GitHub issue

🐛 Bug Report

When using the library with the new Blazor Web App (.NET8 Preview 7) template, I’m not getting any of the styles loading like the Header, etc. The content is rendering, no errors in outputs/console log/etc. just not getting any UI that is expected.

💻 Repro or Code Sample

(install .NET 8 Preview 7)

  1. File…New Blazor Web App
  2. Add 3.0.0-RC1 package and configure project
  3. Add <Header> element to MainLayout
<FluentHeader>
    My Dashboard
</FluentHeader>

🤔 Expected Behavior

Header renders like documentation indicates image

😯 Current Behavior

Header content renders, but nothing else image

Issue Analytics

  • State:open
  • Created a month ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vnbaaijcommented, Aug 19, 2023

@timheuer this how it works with .NET 8 at the moment (JS initializers behavior is not yet finalized, see also https://github.com/dotnet/aspnetcore/issues/50187)

With Blazor’s server-side rendering model, JS initializers don’t get called until interactive components get loaded on the page for the first time. That is, when a WebAssembly component gets added to the page, the beforeStart callback is executed and the WebAssembly runtime loads and starts, then the afterStarted callback executes. Callbacks will be re-executed if a Blazor Server component then gets added to the page.

By using the new template (which generates a SSR site) the module script (that loads the web components script and hooks up the custom events)) does not get called. Adding the web components script tag, as suggested by me before, only solves part of the problem.

I solved it in my copy of a site generated with the template as follows: 1 - Change Program.cs to add .AddServerComponents(), so from

// Add services to the container.
builder.Services.AddRazorComponents();

to

// Add services to the container.
builder.Services.AddRazorComponents().AddServerComponents();

2 - Add @attribute [RenderModeServer] to the Index page directives to force it to be a Server component so library script (.lib.module.js) gets called

I guess adding .AddWebAssemblyComponents(); to Program.cs and @attribute [RenderModeWebAssembly] to Index.razor would have the same effect.

1reaction
vnbaaijcommented, Aug 18, 2023

Thanks @vnbaaij – got the UI working…interactivity is not (sorting does nothing on clicking on the grid now)

The behavior has changed with . NET 8. I’m in contact with Mackinnon to see what would be a solution for this

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core updates in .NET 8 Preview 3
NET 8 Preview 3 is now available and includes many great new improvements to ASP.NET Core. Here's a summary of what's new in...
Read more >
ASP.NET Core updates in .NET 8 Preview 6
In this preview release we've removed the Blazor Server template and the “ASP.NET Core hosted” option from the Blazor WebAssembly template. Both ...
Read more >
Blazor WebAssembly 3.1 Target Framework is missing
A Blazor WebAssembly App, unlike Blazor Server App , runs under the Mono runtime. It is not .Net Core. Just add the project...
Read more >
c# - Blazor the type or namespace name 'App' could not be ...
I have setup the basic application in Blazor in Microsoft Visual Studio Community 2019 Version 16.1.3 and I have tried both of the...
Read more >
Blazor Hybrid Web Apps with .NET MAUI
NET MAUI. MAUI provides a set of technologies that enable apps to run on Web, desktop, and mobile. This new pattern is named...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found