为什么当我将根更改为文件夹“_framework”时 blazor 应用程序不起作用

Why blazor app doesn't work when i change root to folder "_framework"

我在 index.html 中更改了我的基本 href:href="/" 变成了 href="/schedule/"

我也改Configure:

 app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(),@"Schedule.Client", @"dist")),
                RequestPath = new PathString("/schedule")
            });

这里是我的文件

css, js, resources 工作正常,但是包含 wasm 文件的 _framework 不能正常工作。

index.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width">
    <title>Schedule</title>
    <link rel="icon" href="css/Resources/icon_title.png" />
    <base href="/schedule/" />
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" crossorigin="anonymous">
    <link href="css/site.css" rel="stylesheet" />
    <link href="css/btnstyle.css" rel="stylesheet" />
    <script src="js/SetScroll.js"></script>

</head>
<body>
    <app>
        <div id="demo" style="margin:auto; top:30px;">
            <img src="css/Resources/logo-fin.png" />
            <div class="circle fas fa-spinner"></div>
        </div>
    </app>

    <script src="_framework/blazor.webassembly.js"></script>
    <script defer src="https://use.fontawesome.com/releases/v5.2.0/js/all.js" crossorigin="anonymous"></script>
</body>
</html>

当我启动我的应用程序时,出现错误

当我使用href="/"时,一切都是正确的

有什么问题吗? 谢谢!

更新

我发现了相同的问题和解决方案,但使用的是 Azure CLI: https://anthonychu.ca/post/blazor-azure-storage-static-websites/

我在 github 上问了这个问题并得到了答案。您应该使用一种方法来设置正确的根:https://github.com/aspnet/Blazor/issues/1421

app.Map("/schedule", subdirApp =>
{
    subdirApp.UseBlazor<Startup>();
});

我在 Server.Startup 中编写了这段代码。 在 UseBlazor 中我写了 Client.Startup.