Search code examples
c#asp.net-corerazorblazorwebassembly

Routable componet of Razor Class Library not displayed in ASP.NET Core 6.0 WebAssembly


I have an ASP.NET Core 6.0 WebAssembly in which I have included a Razor class library. The library contains several components, including three that use the @page directive. After a login (implemented with IdentityServer4) it is directed to one of the routable components from the library. The problem: the component is not displayed...

I checked the following:

  • The library is referenced by the WebAssembly
  • In App.razor I added AdditionalAssemblies="new[] { typeof(Helper).Assembly, typeof(Confirmation).Assembly, typeof(HelperRegistration).Assembly }".

I found the following:

  • No errors are displayed in either the Visual Studio output or the browser DevTools console.
  • Nothing is noticeable in the Network tab of Browser DevTools.
  • protected async override Task OnInitializedAsync() of the routable component is called.

I tried this:

  • Call the StateHasChanged() method of the layout component from the OnInitializedAsync() method. The idea behind it was that Trigger rendering of the component from the library.

The components in the Razor class library were previously implemented directly in the Blazor WebAssembly and that's how it all worked! My goal is to integrate the library later with lazy load.


Solution

  • I found the mistake. It wasn't the display of components, it was the way I integrated the navigation menu. This was not displayed as I expected, but it was correct that no component was displayed at that moment.

    The hints helped me to find the cause of my error. Thank you!