The problem
In a .NET 6.0 Blazor WebAssembly application, when setting pathbase
in launchSettings.json
, the debugger fails to attach. Using Visual Studio 2022 (v. 17.0.2).
在.NET 6.0 Blazor WebAssembly应用程序中,当在LaunchSettings.json中设置路径库时,调试器无法附加。使用Visual Studio 2022(v17.0.2)。
The Code
wwwroot/index.html
<base href="/app/" />
launchSettings.json
"profiles": {
"MyApp.UI": {
"commandName": "Project",
"commandLineArgs": "--pathbase=/app",
"launchBrowser": true,
"launchUrl": "app",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"hotReloadEnabled": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7177;http://localhost:5177",
"dotnetRunMessages": true
}
}
Without "commandLineArgs": "--pathbase=/app"
, the app runs fine and the debugger attaches - although, it's not at the right base path.
如果没有“CommandLineArgs”:“--pathbase=/app”,应用程序运行良好,调试器也会附加--尽管它不在正确的基本路径上。
With "commandLineArgs": "--pathbase=/app"
, I get the following error:
使用“CommandLineArgs”:“--pathbase=/app”时,我得到以下错误:
更多回答
优秀答案推荐
Only workaround I could find:
我能找到的唯一解决办法是:
Change debug web browser to chrome, edge throws the error.
Change inspect uri to include the subpath:
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/app/_framework/debug/ws-proxy?browser={browserInspectUri}",
更多回答
我是一名优秀的程序员,十分优秀!