✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
When I run my C# Webapi project through Visual Studio Code debugger (or VS) then my reactapp can make a GET request to the webapi, however if I start up the webapi via cmd
dotnet run
dotnet run
and make a GET request I get
net::ERR_CONNECTION_REFUSED
net::ERR_CONNECTION_REFUSED
This is the output from VS Code when I start the webapi through the debugger.
* Executing task: C:\Program Files\dotnet\dotnet.exe build C:\Users\Username\source\repos\Username\InsuranceCalculator/InsuranceCalculator.sln /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary MSBuild version 17.6.1+8ffc3fe3d for .NET Determining projects to restore... All projects are up-to-date for restore. webapi -> C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi\bin\Debug\net7.0\webapi.dll * Terminal will be reused by tasks, press any key to close it.
* Executing task: C:\Program Files\dotnet\dotnet.exe build C:\Users\Username\source\repos\Username\InsuranceCalculator/InsuranceCalculator.sln /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary MSBuild version 17.6.1+8ffc3fe3d for .NET Determining projects to restore... All projects are up-to-date for restore. webapi -> C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi\bin\Debug\net7.0\webapi.dll * Terminal will be reused by tasks, press any key to close it.
This is the output from cmd when I start the webapi through the cmd.
C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi>dotnet runBuilding...info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5206info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.info: Microsoft.Hosting.Lifetime[0] Hosting environment: Developmentinfo: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi
C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi>dotnet runBuilding...info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5206info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.info: Microsoft.Hosting.Lifetime[0] Hosting environment: Developmentinfo: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi