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?
.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.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With