【问题标题】:Blazor server error 400 fails to negotiate to server when using routing使用路由时,Blazor 服务器错误 400 无法与服务器协商
【发布时间】:2020-07-04 10:58:15
【问题描述】:

描述错误

如附件截图所示,我正在使用路由:

@page "/addbrand/{BrandId:guid}"

当我刷新 url https://localhost:44379/addBrand/1abc52f3-c371-4566-847d-1a986f093396 时,这会导致错误 400 无法加载资源,因为 balzor 协商的 url 更改为 https://localhost:44379/addBrand/_blazor/negotiate?negotiateVersion=1 而不是 https://localhost:44379/_blazor/negotiate?negotiateVersion=1

https://localhost:44379/addBrand/_framework/blazor.server.js 而不是 https://localhost:44379/_framework/blazor.server.js

这发生在 _host.cshtml 文件中的所有链接上。

有例外吗?是的,浏览器控制台日志: [2020-03-23T21:57:35.846Z] 信息:将“_blazor”规范化为“https://localhost:44379/addBrand/_blazor”。 _blazor/negotiate?negotiateVersion=1:1 加载资源失败:服务器响应状态为400() blazor.server.js:1 [2020-03-23T21:57:35.917Z] 错误:无法完成与服务器的协商:错误

更多技术细节

  • ASP.NET Core 版本:3.1
  • IDE:VS 2019

我已经在github举报了

【问题讨论】:

    标签: blazor blazor-server-side


    【解决方案1】:

    在您的_Host.cshtml 中将<base href 标签网址设置为~/

    <head>
    ...
        <base href="~/" />
    ...
    </head>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-01
      • 1970-01-01
      • 2023-01-14
      • 2012-11-13
      • 2022-01-22
      相关资源
      最近更新 更多