Blazor (WASM) 和 Web Api 分开项目调试
Blazor (WASM) and Web Api separate Project Debugging
我在调试 Blazor Web 程序集项目时遇到问题。
设置:
- WASM Blazor UI 项目
- 引用 WASM 项目的 Web API 项目
- 它们共享同一个端口。
- 我只启动 Web API 项目并且还可以访问 blazor 站点。 (这对我来说很奇怪)
我的 Web Api 项目中有这两行。
app.UseWebAssemblyDebugging();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
endpoints.MapFallbackToFile("index.html");
});
启动设置 Web API:
"API": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
启动设置 Blazor WASM:
"Lab.Web": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
当我尝试在我的 Blazor 项目中的某处放置断点时。我收到此消息:
“当前不会命中断点。没有为该文档加载任何符号。”
如果我单独 运行 Blazor 项目,我不会收到此消息,但我无法访问我的 Web API。
在能够调试 WASM 项目的同时为 Web API 和 Blazor WASM 共享同一端口的正确方法是什么?
ps: 如果这个帮助ps 我正在使用 VS Studio 16.9.3。
非常感谢您的帮助!
我假设:
- 您是 运行 AspNetCore 中的项目而不是 IIS。
- 您将 API 服务器项目作为您的启动项目。
- 您处于调试模式。
- 您的设置类似于托管在 ASPNetCore 模板上的 Web Assembly。
您唯一需要 inspectUri
的地方在 LaunchSettings.json 中,在 API 项目中,这是您没有的地方。
在调试模式下启动时可能会很慢,所以给它时间。
我在调试 Blazor Web 程序集项目时遇到问题。
设置:
- WASM Blazor UI 项目
- 引用 WASM 项目的 Web API 项目
- 它们共享同一个端口。
- 我只启动 Web API 项目并且还可以访问 blazor 站点。 (这对我来说很奇怪)
我的 Web Api 项目中有这两行。
app.UseWebAssemblyDebugging();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
endpoints.MapFallbackToFile("index.html");
});
启动设置 Web API:
"API": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
启动设置 Blazor WASM:
"Lab.Web": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
当我尝试在我的 Blazor 项目中的某处放置断点时。我收到此消息:
“当前不会命中断点。没有为该文档加载任何符号。”
如果我单独 运行 Blazor 项目,我不会收到此消息,但我无法访问我的 Web API。
在能够调试 WASM 项目的同时为 Web API 和 Blazor WASM 共享同一端口的正确方法是什么?
ps: 如果这个帮助ps 我正在使用 VS Studio 16.9.3。
非常感谢您的帮助!
我假设:
- 您是 运行 AspNetCore 中的项目而不是 IIS。
- 您将 API 服务器项目作为您的启动项目。
- 您处于调试模式。
- 您的设置类似于托管在 ASPNetCore 模板上的 Web Assembly。
您唯一需要 inspectUri
的地方在 LaunchSettings.json 中,在 API 项目中,这是您没有的地方。
在调试模式下启动时可能会很慢,所以给它时间。