Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 6.0 Stop Swagger from opening automatically on startup

When I run my .Net6.0 web api project in Visual Studio, Swagger UI opens automatically in a new chrome browser. How can I stop this from happening?

like image 342
James Moore Avatar asked Dec 14 '25 18:12

James Moore


1 Answers

.Net 6 integrate Swagger in the template. If you want to not auto open a tab in your browser, then you can comment "launchBrowser": true. If you want to auto open a tab in your browser but not the swagger UI page, then you can comment the variable "launchUrl": "swagger", then a new tab will open automatically and direct to the home url like https://localhost:7280 in my test example.

Open your launchSettings.json file and comment all variables "launchBrowser": true. In my screenshot below, since I didn't start my api app with IIS express, so I didn't comment this variable in IIS Express.

enter image description here

like image 68
Tiny Wang Avatar answered Dec 16 '25 17:12

Tiny Wang