Blazor 服务器错误 400 无法在使用路由时协商到服务器
Blazor server error 400 fails to negotiate to server when using routing
描述错误
如附件截图所示,我正在使用路由:
@page "/addbrand/{BrandId:guid}"
当我刷新 url https://localhost:44379/addBrand/1abc52f3-c371-4566-847d-1a986f093396 this lead to error 400 Failed to load resource as the url of balzor negotation changed to 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核心版本:3.1
- IDE:VS 2019
我已在 github
上报告
在您的 _Host.cshtml
中将 <base href
标签 url 设置为 ~/
<head>
...
<base href="~/" />
...
</head>
描述错误
如附件截图所示,我正在使用路由:
@page "/addbrand/{BrandId:guid}"
当我刷新 url https://localhost:44379/addBrand/1abc52f3-c371-4566-847d-1a986f093396 this lead to error 400 Failed to load resource as the url of balzor negotation changed to 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核心版本:3.1
- IDE:VS 2019
我已在 github
上报告在您的 _Host.cshtml
中将<base href
标签 url 设置为 ~/
<head>
...
<base href="~/" />
...
</head>