Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Pages displaying incorrectly in production mode

$
0
0

I have a Blazor .net 7 webpage project tin visual studio 2022. When running the executable from the Visual studio environment in a Development profile (in launchsettings.json) everything works as expected.

However, once I change this to “Production”, while keeping everything else the same, the pages do not render correctly. The navigation menu is missing and the rest of the page looks more basic.

I suspect that it cannot see the CSS and other pages and this is causing the problem, however this is just my guess.

I've included a copy of the profiles below, the profile one works correctly, and the profile production one causes the error.

"profiles": {"Project": {"commandName": "Project","dotnetRunMessages": true,"launchBrowser": true,"applicationUrl": "https://localhost:7254;http://localhost:5254","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development"    }  },"Project-Production": {"commandName": "Project","dotnetRunMessages": true,"launchBrowser": true,"applicationUrl": "https://localhost:7254;http://localhost:5254","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Production"    }  }}

Here is the relevant code for creating the web application:

var builder = WebApplication.CreateBuilder(args);builder.Logging.AddLog4Net();// Add services to the container.Configure(builder.Services);var app = builder.Build();ConfigureApp(app);app.RunAsync();private static void Configure(IServiceCollection services){    services.AddRazorPages();    services.AddServerSideBlazor();    services.AddHttpClient();    services.AddMudServices();    services.AddScoped<DialogService>();    services.AddScoped<NotificationService>();    services.AddScoped<TooltipService>();    services.AddScoped<ContextMenuService>();}private static void ConfigureApp(WebApplication app){    // Configure the HTTP request pipeline.    if (!app.Environment.IsDevelopment())    {        app.UseExceptionHandler("/Error");        // 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.UseRouting();    app.MapBlazorHub();    app.MapFallbackToPage("/_Host");}

I'm fairly new to programming with web projects, so I imagine that it's something fairly basic that I have missed, but I cannot seem to find it! I have checked other posts on Stack overflow and couldn't find anything that has helped me.

Thanks for any help in advance!


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>