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

How to set base path for a Mud Blazor App

$
0
0

I have created a very simple mud blazor app but for some odd reason the base path is not being respected. This is my program.cs

var builder = WebApplication.CreateBuilder(args);// Add MudBlazor servicesbuilder.Services.AddMudServices();// Add services to the container.builder.Services.AddRazorComponents()    .AddInteractiveWebAssemblyComponents();var app = builder.Build();app.UsePathBase("/foo/bar");// Configure the HTTP request pipeline.if (app.Environment.IsDevelopment()){    app.UseWebAssemblyDebugging();}else{    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.UseStaticFiles(new StaticFileOptions(){    RequestPath = "/foo/bar",    ServeUnknownFileTypes = true,});app.UseAntiforgery();app.MapRazorComponents<App>()    .AddInteractiveWebAssemblyRenderMode()    .AddAdditionalAssemblies(typeof(MudBlazorWebApp1.Client._Imports).Assembly);app.Run();

When I run this, it works when I target the address https://localhost:44381/ but I am expecting to hit on https://localhost:44381/foo/bar but when I do this it fails to load up the assets like CSS and mublazor.min.js etc

What am I doing wrong here?

enter image description here


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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