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

问题描述 投票:0回答:1

我改变了我在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")
            });

这里找到我的文件

Here located my files:

css,js,资源运行良好,但_framework包含wasm文件并且无法正常工作。

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>

当我启动我的应用程序时,我得到错误enter image description here

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

可能有什么不对?谢谢!

更新

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

enter image description here

asp.net-core blazor
1个回答
0
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.