Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How do I get Blazor Server and Blazor WebAssembly to run side-by side so I may utilise the new features of .NET 8?

$
0
0

How do I get Blazor Server and Blazor WebAssembly to run side-by side so I may utilise the new features of .NET 8?

I have a .NET 8 core application utilising client-side rendering (CSR) using Blazor WebAssembly. It's a none-trivial application using services instantiated by the client (for authentication, uistate, local storage etc.).

I would like to implement a handful of server-side rendered pages (Login pages, and redirection) that do not require the full WebAssembly to load.

The WebAssembly client works, as per MS docs:

<Routes @rendermode="new InteractiveWebAssemblyRenderMode(prerender: false)" />

and

<Router AppAssembly="@typeof(Client.Program).Assembly">

To get server side rendering to work, I can implement

<Routes />

and

<Router AppAssembly="@typeof(Sever.Program).Assembly">

With this configuration, I can render pages server-side, and even render some (trivial) WebAssembly components. However, when doing so, the WebAssembly entry point is no longer invoked (ie WebAssembly.Program() is not executed) and the WebAssembly client is not set up to run correctly. I end up with server errors describing a failure to instantiate client only objects (ie localStorage) for the substantial part.

How do I get Blazor Server and Blazor WebAssembly to run side-by side so I may utilise the new features of .NET 8?

I expect (hope!) the answer lies in one (or all) of the following

  • modification of <Routes> such that certain urls reference a different AppAssembly (?!)
  • modification of endpoints.MapRazorComponents<App>() to identify between WebAssembly parts from Server parts
  • anything else!(!?)

With many thanks in advance.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>