.netasp.net-coreblazor

.net blazor new debug profile lacks .css .js why? / no css / not applied css


i have some .net blazor serverside project that use MudBlazor for FrontEnd

i neded to add new debug profile for test env. so i did copy defauld debug profile renamed id to httpsTest and changed env variable as on screen

enter image description here

i created new appsettings called appsettings.TestEnvDevelopment.json

and everything works great except css

when i run this debugTest profile i have no mudblazor / errors css as on screen

enter image description here

when i run nodmal profile / css is ok and everything else also

so the question is

how to handle this properly ? what i did forget ? there i need to add this ?

thanks and regards !


Solution

  • Add below settings in Program.cs file, it will work properly.

    builder.WebHost.UseWebRoot("wwwroot");
    builder.WebHost.UseStaticWebAssets();
    

    Reason

    Consume content from a referenced RCL

    enter image description here

    Full Code

    using BlazorApp1.Components;
    using MudBlazor.Services;
    
    var builder = WebApplication.CreateBuilder(args);
    
    builder.WebHost.UseWebRoot("wwwroot");
    builder.WebHost.UseStaticWebAssets();
    
    // Add services to the container.
    builder.Services.AddRazorComponents()
        .AddInteractiveServerComponents();
    
    builder.Services.AddMudServices();
    
    
    var app = builder.Build();
    
    // Configure the HTTP request pipeline.
    if (!app.Environment.IsDevelopment())
    {
        app.UseExceptionHandler("/Error", createScopeForErrors: true);
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
        app.UseHsts();
    }
    
    app.UseHttpsRedirection();
    
    app.UseStaticFiles();
    app.UseAntiforgery();
    
    app.MapRazorComponents<App>()
        .AddInteractiveServerRenderMode();
    
    app.Run();