Search code examples
c#blazorshared-librariesmauirazor-pages

RCL with pages to use in MAUI app and Blazor server app .Net 8.0


I want to create a Blazor server app and MAUI app both sharing same UI. I have done the following

  1. Create a RCL (Razor class library) project
  2. Create a MAUI project
  3. Create a Blazor server app project
  4. Link MAUI and Blazor server app projects to use RCL
  5. Add namespace to _Imports.razor file
  6. Add additional assemblies attribute
  7. Create a weather page to RCL
  8. Remove original weather page from both MAUI and server App

Now MAUI app shows the weather page without any issue. Server App on the other hand generated 404 error. Not able to get this work.

Components work fine but when it comes to pages it's not working in server app. I have uploaded to https://github.com/udayakumarlm/CommonUI.

Any suggestions ?


Solution

  • You've set up the Router to see the library assembly, but Weather is a static SSR (static server-side rendering) page, not an Interactive page.

    You need to add the additional assembly to the Razor middleware handler so it can see it.

    app.MapRazorComponents<App>()
        .AddInteractiveServerRenderMode()
        .AddAdditionalAssemblies(new[] { typeof(RazorClassLibrary1.TestClass).Assembly });