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 services
builder.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?
set the base herf in your app.razor:
<base href="/foo/bar/" />