So setzen Sie den Basispfad für eine Schlammblazor -App
Posted: 20 Feb 2025, 12:08
Ich habe eine sehr einfache Mud Blazor -App erstellt, aber aus irgendeinem Grund wird der Basispfad nicht respektiert. Dies ist mein Programm.cs < /p>
Wenn ich dies ausführe, funktioniert es, wenn ich die Adresse https: // localhost: 44381/ abziele, aber ich erwarte, auf https: // localhost: 44381/zu klettern. foo/bar Aber wenn ich dies tue /> Was mache ich hier falsch? />
Code: Select all
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()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(MudBlazorWebApp1.Client._Imports).Assembly);
app.Run();