Radzen Blazor Components don't respect "custom" environments

I have a server side blazor project I work on at home and the office. My configuration is slightly different between machines, so I setup an ASPNETCORE_ENVIRONMENT value on my home box of "Home" and made myself an "appsettings.Home.json" for my custom settings. The problem is that Radzen css/js then fails to load with 404s.

I'm still getting acquainted with how .NET Core handles environments, so maybe I'm missing something obvious, but the rest of the application seems to work OK (and pulls my settings from the correct json file), just seems like Radzen is defaulting to Production mode if it's not explicitly "Development". Is there some way to override that?

EDIT: I'm running latest 2.1.23 fwiw

Hi @Brendan_Sullivan,

You have probably hit this issue with static web assets (not specific to Radzen). The discussion continues here. The official instructions say that assets work by default in Development only. During publish they are extracted and copied in the wwwroot directory. Long story short if you don't have "ASPNETCORE_ENVIRONMENT": "Development" you should invoke UseStaticWebAssets

1 Like

Oh, yeah that looks like it. It's currently pretty bare bones so the Radzen components were the only thing that was getting broken by that and it led me down the wrong rabbit trail :wink: Thanks for the links

sorry to bump an old thread, but I'm hitting this issue after pushing my site (which works locally with Development environment setting) to azure app service (with Production as the setting)...

I tried to set the UseStaticWebAssets, but am unsure how to do this in .net 6.... I tried a few examples I found around the internet but keep getting this error:

Changing the host configuration using WebApplicationBuilder.WebHost is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.

which I wans't able to figure out how to do...

how can I resolve this issue with .net 6 server side blazor?

many thanks!

aha, seconds after posting this I realized I could change the version in the linked documentation to .net 6: Reusable Razor UI in class libraries with ASP.NET Core | Microsoft Docs

which suggests to add this:


that seems to resolve the exception I was getting, but I still have a 404 on the razden assets!

is there anything more I need to make this work on .net 6?

Static web assets should not be used in production. When you publish your application (via dotnet publish) they are copied to the wwwroot directory and served from there.

that's what I understood, but when publishing my site to app service with production setting, i was getting the 404 error...

but it turns out there was just something wonky with my setup. I explored the published files and it had references to the telerik trial assets i had installed previous to radzen while testing, and had fully removed them long ago, so something was caching or something..

I did a solution clean and restarted vs and deleted the obj folder and apparently something there fixed it because it finally republished and I see the radzen assets deployed after all.

so, false alarm -- ish? thanks for the help tho, bottom line is i'm back in business, love the controls, thanks!!