.NET8 render modes break RadzenComponents #1008

Closed
opened 2026-01-29 17:47:41 +00:00 by claunia · 2 comments
Owner

Originally created by @XorZy on GitHub (Oct 12, 2023).

Describe the bug
.NET8 new render modes break RadzenComponents

To Reproduce
-Create a Blazor Server App with .NET8 RC2
-Add the required js, css and services
-Add RadzenComponents to the main layout

Expected behavior
DialogService.Open should work in components with RenderModeInteractiveServer.

Actual behavior
DialogService.Open does not work, nothing happens.

This is issue, from my understanding that layouts are rendered as static components, therefore the RadzenComponents in the layout will not be accessible from any interactive component further down. It appears to be impossible to set the rendermode for a specific layout (https://github.com/dotnet/aspnetcore/issues/50518).

I have found only two ways to get RadzenComponents to work with .NET8

  • You include them in any component that needs them, which seems quite cumbersome, and I am not sure what would happen if you end up having more that one Dialog in a given page.
  • Or you set the entire app to RenderModeInteractiveServer by setting @rendermode in the Routes component

With the second method you effectively lose the ability to use SSR, which can be problematic if you plan to use the new Blazor Identity Components, which do not work in interactive mode.
I don't think there is a way to make a specific component static so once the route is set to interactive any component or page will also be interactive.

Am I missing something?

What is the recommended way to add RadzenComponents with NET8?

Originally created by @XorZy on GitHub (Oct 12, 2023). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **Describe the bug** .NET8 new render modes break RadzenComponents **To Reproduce** -Create a Blazor Server App with .NET8 RC2 -Add the required js, css and services -Add RadzenComponents to the main layout **Expected behavior** DialogService.Open should work in components with RenderModeInteractiveServer. **Actual behavior** DialogService.Open does not work, nothing happens. This is issue, from my understanding that layouts are rendered as static components, therefore the RadzenComponents in the layout will not be accessible from any interactive component further down. It appears to be impossible to set the rendermode for a specific layout (https://github.com/dotnet/aspnetcore/issues/50518). I have found only two ways to get RadzenComponents to work with .NET8 - You include them in any component that needs them, which seems quite cumbersome, and I am not sure what would happen if you end up having more that one Dialog in a given page. - Or you set the entire app to RenderModeInteractiveServer by setting @rendermode in the Routes component With the second method you effectively lose the ability to use SSR, which can be problematic if you plan to use the new Blazor Identity Components, which do not work in interactive mode. I don't think there is a way to make a specific component static so once the route is set to interactive any component or page will also be interactive. Am I missing something? What is the recommended way to add RadzenComponents with NET8?
Author
Owner

@akorchev commented on GitHub (Oct 12, 2023):

Duplicate of https://github.com/radzenhq/radzen-blazor/issues/1183. Check the linked forum thread for explanation and workarounds.

This thread also shows how to use <RadzenDialog /> in a static layout: https://forum.radzen.com/t/multiple-declarations-of-radzen-services-needed-for-net-8-rc1-render-modes/15410/2?u=korchev:

<RadzenDialog @rendermode="@RenderMode.InteractiveServer" />
@akorchev commented on GitHub (Oct 12, 2023): Duplicate of https://github.com/radzenhq/radzen-blazor/issues/1183. Check the linked forum thread for explanation and workarounds. This thread also shows how to use `<RadzenDialog />` in a static layout: https://forum.radzen.com/t/multiple-declarations-of-radzen-services-needed-for-net-8-rc1-render-modes/15410/2?u=korchev: ``` <RadzenDialog @rendermode="@RenderMode.InteractiveServer" /> ```
Author
Owner

@akorchev commented on GitHub (Oct 12, 2023):

Decided to pin this issue as I suspect this question will be asked a lot.

Here is the situation with Blazor 8 rendering modes and Blazor UI components (Radzen.Blazor or any other library or built-in component).

The default Blazor 8 web application template uses static rendering mode by default. In static mode events are not fired and components can't handle them. This is by Microsoft design and will not change. This is why components added to MainLayout.razor (or any other component with static render mode) won't appear to work - they will not respond to user interaction.

One cannot set a render mode for a layout (also by design) - it has to be enabled up the hierarchy for example for the <Routes /> component -> <Routes @rendermode="@RenderMode.InteractiveServer" />. This however disables static mode globally.

A workaround is to specify the render mode per component e.g. <RadzenDialog @rendermode="@RenderMode.InteractiveServer" />. This has problems too - a component with render mode set cannot have child content so you cannot set it to <RadzenPanelMenu> - its items are specified as child content.

If you want to have interactive "island" in a static page you have to define a component which has the render mode set via attribute: @attribute [RenderModeInteractiveServer] or @attribute [RenderModeInteractiveWebAssembly] or even @attribute [RenderModeInteractiveAuto]. For example

<RadzenNotification @rendermode="@RenderMode.InteractiveServer" />
<RadzenDialog @rendermode="@RenderMode.InteractiveServer" />
<RadzenLayout style="height: 400px">
    <Navigation /> <!-- This contains the interactive sidebar and toggle -->
    <RadzenBody>
        <div class="rz-p-4">
            @Body
        </div>
    </RadzenBody>
    <RadzenFooter>
        Footer
    </RadzenFooter>
</RadzenLayout>

There are Radzen.Blazor components that don't use events and do not require any non-static render mode - RadzenCard, RadzenRow, RadzenStack, RadzenBadge and a few others.

For additional info check these threads:

https://forum.radzen.com/t/sidebar-not-working-in-net-8-rc1-experiment/15198/13
https://forum.radzen.com/t/radzen-net-8-rc1-render-mode-support/15379
https://forum.radzen.com/t/multiple-declarations-of-radzen-services-needed-for-net-8-rc1-render-modes/15410

@akorchev commented on GitHub (Oct 12, 2023): Decided to pin this issue as I suspect this question will be asked a lot. Here is the situation with Blazor 8 rendering modes and Blazor UI components (Radzen.Blazor or any other library or built-in component). The default Blazor 8 web application template uses static rendering mode by default. In static mode events are not fired and components can't handle them. This is by Microsoft design and will not change. This is why components added to MainLayout.razor (or any other component with static render mode) won't appear to work - they will not respond to user interaction. One cannot set a render mode for a layout (also by design) - it has to be enabled up the hierarchy for example for the `<Routes />` component -> `<Routes @rendermode="@RenderMode.InteractiveServer" />`. This however disables static mode globally. A workaround is to specify the render mode per component e.g. `<RadzenDialog @rendermode="@RenderMode.InteractiveServer" />`. This has problems too - a component with render mode set cannot have child content so you cannot set it to `<RadzenPanelMenu>` - its items are specified as child content. If you want to have interactive "island" in a static page you have to define a component which has the render mode set via attribute: `@attribute [RenderModeInteractiveServer]` or `@attribute [RenderModeInteractiveWebAssembly]` or even `@attribute [RenderModeInteractiveAuto]`. For example ``` <RadzenNotification @rendermode="@RenderMode.InteractiveServer" /> <RadzenDialog @rendermode="@RenderMode.InteractiveServer" /> <RadzenLayout style="height: 400px"> <Navigation /> <!-- This contains the interactive sidebar and toggle --> <RadzenBody> <div class="rz-p-4"> @Body </div> </RadzenBody> <RadzenFooter> Footer </RadzenFooter> </RadzenLayout> ``` There are Radzen.Blazor components that don't use events and do not require any non-static render mode - RadzenCard, RadzenRow, RadzenStack, RadzenBadge and a few others. For additional info check these threads: https://forum.radzen.com/t/sidebar-not-working-in-net-8-rc1-experiment/15198/13 https://forum.radzen.com/t/radzen-net-8-rc1-render-mode-support/15379 https://forum.radzen.com/t/multiple-declarations-of-radzen-services-needed-for-net-8-rc1-render-modes/15410
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1008