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

Blazor Web App (.NET 8): How to use a server rendered component, on a WebAssembly rendered page?

$
0
0

Lets say i have a WebAssembly rendered page in a Blazor Web App (.NET 8):

@page "/counter"@rendermode InteractiveWebAssembly<PageTitle>Counter</PageTitle><h1>Counter</h1><p role="status">Current count: @currentCount</p><button class="btn btn-primary" @onclick="IncrementCount">Click me</button><ServerSideComponent></ServerSideComponent>@code {    private int currentCount = 0;    private void IncrementCount()    {        currentCount++;    }}

And i have a Razor component with server side rendering:

@rendermode InteractiveServer<p role="status">Current count: @currentCount</p><button class="btn btn-primary" @onclick="IncrementCount">Click me</button>@code {    private int currentCount = 0;    private void IncrementCount()    {        currentCount++;    }}

Is there a way of having a server side rendered blazor component, on a WebAssembly rendered page? I want the page to be rendered in WebAssembly, and the component to be server rendered.

When i try doing this, i get this exception:

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]Unhandled exception rendering component: Cannot create a component of type 'BlazorApp4.Client.ServerSideComponent' because itsrender mode'Microsoft.AspNetCore.Components.Web.InteractiveServerRenderMode' isnot supported by WebAssembly rendering. System.NotSupportedException:Cannot create a component of type'BlazorApp4.Client.ServerSideComponent' because its render mode'Microsoft.AspNetCore.Components.Web.InteractiveServerRenderMode' isnot supported by WebAssembly rendering.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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