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

如何阻止.NET 6.0 Web API启动时自动打开Swagger UI

阻止.NET 6.0 Web API项目运行时自动打开Swagger UI的方法

有两种常用方式可以实现:

方法一:通过项目属性设置

  • 右键点击项目,选择「属性」
  • 切换到「调试」选项卡
  • 在「启动浏览器」下拉列表中选择「无」
  • 保存设置后重新运行项目,浏览器就不会自动启动了

方法二:修改launchSettings.json配置文件

  • 打开项目根目录下Properties文件夹中的launchSettings.json文件
  • 找到profiles节点下对应你使用的启动配置(通常是http或https)
  • 将配置项中的launchBrowser值从true修改为false
  • 示例修改后的配置片段:
"profiles": {
  "http": {
    "commandName": "Project",
    "dotnetRunMessages": true,
    "launchBrowser": false,
    "applicationUrl": "http://localhost:5000",
    "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Development"
    }
  },
  "https": {
    "commandName": "Project",
    "dotnetRunMessages": true,
    "launchBrowser": false,
    "applicationUrl": "https://localhost:5001;http://localhost:5000",
    "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Development"
    }
  }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 14:25:28