Mud Blazor应用设置基础路径后资源加载失败,求排查配置问题
Mud Blazor应用设置基础路径后资源加载失败,求排查配置问题
我创建了一个非常简单的Mud Blazor应用,但不知道为什么基础路径没有生效。这是我的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();
当我运行应用时,访问https://localhost:44381/是正常的,但我期望的是通过https://localhost:44381/foo/bar访问。然而当我访问这个地址时,CSS、mudblazor.min.js等资源都加载失败了。
我到底哪里配置错了?

备注:内容来源于stack exchange,提问作者Dr Schizo
相关产品推荐
相关产品推荐

