【问题标题】:Blazor WASM page refresh cannot find CSS or jsBlazor WASM 页面刷新找不到 CSS 或 js
【发布时间】:2021-09-05 13:41:30
【问题描述】:

我有一个 Blazor 页面,当我通过 URL 链接和菜单导航到它时可以正常工作。但是,一旦进入页面,如果我点击 Chrome Refresh 按钮,我会得到一长串 404 错误列表,其中包含我所包含的所有 CSS 和 JS 文件。如果我输入 URL 以直接转到该页面,也会发生这种情况。 Index.razor 页面加载正常。 A-tags 和 NavigationManagers 也可以按预期工作。 URL 是“https://localhost:5001/OrderEdit/223821”,其中 OrderEdit 是页面名称,后跟订单号。页面指​​令如下所示

@page "/OrderEdit"
@page "/OrderEdit/{OrderNumStr}"

当我刷新页面时,我得到了这个(为简洁起见)

GET https://localhost:5001/OrderEdit/bootstrap/css/bootstrap.min.css?v=1 net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/css/Chart.min.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/css/app.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/css/site.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/bootstrap/css/custom.css?v=1 net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/_content/Blazorise/blazorise.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/_content/Blazorise.Bootstrap/blazorise.bootstrap.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/_content/AntDesign/css/ant-design-blazor.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/_content/Blazored.Typeahead/blazored-typeahead.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/_content/BlazorDateRangePicker/daterangepicker.min.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/_content/Sotsera.Blazor.Toaster/toastr.min.css net::ERR_ABORTED 404
GET https://localhost:5001/OrderEdit/_framework/blazor.webassembly.js net::ERR_ABORTED 404

【问题讨论】:

  • 您的 index.html 的 head 中有 <base href="/" /> 吗?看起来不是 - 因为它正在尝试从 /OrderEdit 获取静态文件
  • 您是否从“应用程序”选项卡(或 FF 中的存储)中清除了 localhost:5001 的浏览器存储空间?
  • 不错!感谢 Magoo 先生, 做到了。

标签: blazor webassembly blazor-webassembly


【解决方案1】:

您的 index.html 的头部是否有 <base href="/" />?看起来不是 - 因为它试图从 /OrderEdit 获取静态文件

【讨论】:

    猜你喜欢
    • 2021-02-25
    • 1970-01-01
    • 2021-07-17
    • 2021-03-01
    • 2021-08-09
    • 2021-08-15
    • 2012-12-19
    • 1970-01-01
    • 2016-11-26
    相关资源
    最近更新 更多