launchSettings.json launchUrl doesn't work "api/values"
Solution 1
The problem is because of Visual Studio for Mac. I was able to get the correct url to chance Run With>Custom Configuration > Run Action --> Debug .Net Core Debugger
Solution 2
I am using VSCode and is happening the same to me, but on Windows. I am just enhancing a bit the answer here.
I have tried VS2019 and it worked in that IDE, so it is supposely to do with VSCode. I have searched for other answers and I found this.
What fixed my issue was to go to .vscode/launch.json file and append:
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}/swagger"
}
as Anton Dremin describes, just add the above into the configurations section.
Related videos on Youtube
Haktan Enes Biçer
Updated on June 04, 2022Comments
-
Haktan Enes Biçer almost 2 years
I am trying to change http://localhost:5001/api/values route but the program is stuck this url.
I read this solutions
How to change the default controller and action in ASP.NET Core API?
How to redirect root to swagger in Asp.Net Core 2.x?
https://medium.com/quick-code/routing-in-asp-net-core-c433bff3f1a4
Everyone write same thing but not work for me.
My
launchSetting.json
file is{ "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:54650", "sslPort": 44382 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, "ShoppingBasketAPI": { "commandName": "Project", "launchBrowser": true, "launchUrl": "swagger", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } }
I tried to change
app.UseMvc();
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-2.2
this is also not working.Where does
api/values
come from? I can't figure out .My controller attribute route is
[Route("api/[controller]/[action]")]