I have an ASP.NET Core 8.0 Blazor application and would like to have a separate Razor library for shared screens and components so these can also be consumed by a .NET Maui app.
I have added the assembly to the router AdditionalAssemblies
and I can navigate from the index page to the page in question, let's say Page 1.
However, when I refresh the page I get a blank screen. Nothing in the console (web or IDE) or browser inspector, apart from the <pre>
tags.
If I move the page into the Web project it works fine and I am able to refresh it. Seems a bit weird that it's acting strangely using a Razor class library.
Web project has been setup with:
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
When you refresh you are pre-rendering. The pre-render Razor HttpRequest
context needs to know about the assembly as well.
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddAdditionalAssemblies(new[] { typeof(Library.xxx).Assembly});