1. ~/blog
  2. technology
Technology

Fix Mud Dialog Issues in Blazor Server

Mud Dialog Not Appearing in Blazor Server .Net 9 Site

While implementing Mud Blazor on this site, I encountered several issues trying to display a simple Mud Dialog. Despite following all the guidance provided in the Mud Blazor Dialog examples, nothing seemed to work.

Eventually, I made one crucial adjustment: I moved the <MudDialogProvider> into the component I was working with. This change enabled the Dialog to function, but it still didn't feel quite right. All the Mud Blazor documentation and examples suggest placing the <MudDialogProvider> within the MainLayout.

After some investigation, I discovered that the root of the problem originated from the configuration of the Blazor site. In my App.razor file, the CascadingAuthenticationState was incorrectly wrapped around the Routes tag. Since .NET 9 uses Dependency Injection for CascadingAuthenticationState, it should not encompass the Routes tag.  

Change:

<CascadingAuthenticationState>
    <Routes />
</CascadingAuthenticationState>

To:

<Routes @rendermode="InteractiveServer" />


After making this change, the Mud Dialogs worked perfectly.

Back to home
share

Comments

0
Add a comment
Enter your name
Your email won't be published
0/1000
Comments are reviewed before they appear.

It's quiet in here. Be the first to comment!

An unhandled error has occurred. Reload ๐Ÿ—™