You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Visual Studio 2022预览版调试ASP.NET Core Web API时弹出传统控制台窗口

解决Visual Studio 2022调试ASP.NET Core Web API弹出传统控制台窗口的方法

方案1:手动修改launchSettings.json

在项目的launchSettings.json文件中,给需要启用外部控制台的profile(比如http或https)添加"externalConsole": true配置项即可。修改后的配置示例如下:

"profiles": {
  "http": {
    "commandName": "Project",
    "dotnetRunMessages": true,
    "launchBrowser": true,
    "launchUrl": "swagger",
    "applicationUrl": "http://localhost:5184",
    "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Development"
    },
    "externalConsole": true
  },
  "https": {
    "commandName": "Project",
    "dotnetRunMessages": true,
    "launchBrowser": true,
    "launchUrl": "swagger",
    "applicationUrl": "https://localhost:7184;http://localhost:5184",
    "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Development"
    },
    "externalConsole": true
  }
}

方案2:通过Visual Studio界面配置

  • 右键项目,选择「属性」
  • 切换到「调试」选项卡
  • 在「控制台」下拉菜单中选择「外部控制台」
  • 保存设置后重新启动调试

添加该配置后,调试ASP.NET Core Web API时就会弹出独立的传统控制台窗口,替代Visual Studio的内置终端。VS2019默认启用外部控制台,而VS2022 17.5.0 Preview这类版本默认使用内置终端,通过上述任一方案即可切换回传统控制台模式。

内容的提问来源于stack exchange,提问作者Large

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 10:45:38