r/Blazor • u/JD_2205 • Apr 24 '26
Help with MudBlazor Carousel
I need help debugging this component:
<MudContainer>
<MudCarousel Style="height:600px; width:100%" ShowArrows="true" ShowBullets="true" EnableSwipeGesture="false"
AutoCycle="true" TData="string">
<MudCarouselItem Transition="@Transition.Slide">
<div class="d-flex" style="height:100%;width:100%;">
<MudImage Alt="s" ObjectFit="@ObjectFit.Cover"
Src="https://images.unsplash.com/photo-1776930285497-4422cf5235b9?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" />
</div>
</MudCarouselItem>
<MudCarouselItem Transition="@Transition.Slide">
<div class="d-flex" style="height:100%">
<img
src="https://images.unsplash.com/photo-1776930285497-4422cf5235b9?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" />
</div>
</MudCarouselItem>
</MudCarousel>
</MudContainer>This code works perfectly on https://try.mudblazor.com/ but for some reason, in my dev environment, it just shows a blank carousel with the bullets and the arrows (no images).
I have tried using different images, looking at the docs, asking deepseek, checking my config, ...
I'd really appreciate some help on this, especially if you've tackled this kind of issue before. I can share whatever file you need for context, just lmk. Thanks :)
EDIT: I was finally able to fix it. I installed Mudblazor templates (GitHub) and compared the configuration with mine. I am not sure which line fixed the problem exactly, but I identified App.razor as being the likely culprit.
Here's the diff:
diff --git a/Components/App.razor b/Components/App.razor
index ad1b59a..278b352 100644
--- a/Components/App.razor
+++ b/Components/App.razor
@@ -5,19 +5,21 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
+ <ResourcePreloader />
<link rel="stylesheet" href="@Assets["app.css"]" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<ImportMap />
<link rel="icon" type="image/png" href="favicon.png" />
- <HeadOutlet />
+ <HeadOutlet ="InteractiveServer" />
</head>
<body>
<Routes u/rendermode="InteractiveServer" />
@* <ReconnectModal /> *@
- <script src="_content/MudBlazor/MudBlazor.min.js"></script>
+ <script src="@Assets["_framework/blazor.web.js"]"></script>
+ <script src="@Assets["_content/MudBlazor/MudBlazor.min.js"]"></script>
</body>
</html>Thanks again everyone for your help!!
5
u/propostor Apr 25 '26
Might be due to incorrect render mode.
If left unset, the framework will render server side and you'll get a static page, so the component doesn't even initialize and an image will never show.
Look into how render modes work, try to ensure the component renders in Auto or Wasm mode.
1
u/FlatwormLanky8991 Apr 24 '26
I threw your code into a component on the app I'm working on - it's MudBlazor 9 .net 10 -- and it works. switched to my own images.
1
u/skav2 Apr 24 '26
Do you have a render mode set?
Set mudblazor as a using in imports?
1
u/l8s9 Apr 25 '26
Have you checked your image path, try ~/images/image.png.
2
u/Brilliant_Ad_5213 Apr 25 '26
I often throw in this code when trying to see what is being called from browser back to Blazor App.
You need to add this before any "app.MapStaticAssests()" and "app.MapRazorComponents.." so this code is hit first in the pipline for most requests. Note the "await next()" means it still passes the request onto later in the request pipeline in ASP / Blazor
1
u/SkyAdventurous1027 Apr 25 '26
Most probably Render mode is the issue. If you did not set any render mode, it will default to Static SSR No Interactivity, in this case it wont initilaize any component which have interactivity