Can't start frontend and backend projects at the same time

Maribel Díaz Galiano 31 Reputation points
2022-11-29T19:48:47.54+00:00

Hi!

I have a problem with the tutorial Create an ASP.NET Core app with Angular - Visual Studio (Windows). It's my first time using Visual Studio 2022 (not Visual Studio Code) to create a solution consisting of a .NET backend and an Angular frontend.

I've followed all the steps until "Start the project" (including it). When you hit the Start button, two command prompts (one for the backend and the other for the frontend) should open but this is what happens to me:

  1. I hit the Start button in VS
  2. Only one command prompt, for the frontend, appears. Inside, it executes npm prestart, and npm start and at the end it shows the message Angular Live Development Server is listening on localhost:4200, open your browser on https://localhost:4200/.
  3. I open the frontend correctly in the browser but there is no backend connection.
  4. I close the command prompt for the frontend.
  5. I get a dialog window saying "There were deployment errors. Continue?".
    a. If I click "No", all processes that might be running terminate and nothing happens. But I notice a new message in the Output box in VS saying An exception happened at deploy, the port 4200 configured on launch.json is unavailable.. Then I ask myself: "But... I only want to build and start the project, not deploying it...". Is this message telling me something?
    b. If I click "Yes" the command prompt for the backend starts correctly, and two URL's open in the browser: https://localhost:7237/swagger/index.html and https://localhost:4200/ (the URL for the frontend, but the frontend is down at this point!).

What can I be doing wrong?

Edit:
I tried starting backend and frontend manually and it works perfect. That makes me think that the problem seems to be related to VS and how it starts the projects when I hit the Start button.

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | Visual Studio | Debugging
{count} votes

Accepted answer
  1. Kreis Roland 96 Reputation points
    2022-12-03T22:12:58.937+00:00

    Hi

    I had the same behavior: Frontend App was started, and blocked to start the Backend App...

    I used Node.js version 18.12.1 (node-v18.12.1-x64.msi). After a downgrade to version 16.18.1 (node-v16.18.1-x64.msi), everything worked fine, both apps were started in Visual Studio 2022.

    https://nodejs.org/download/release/v16.18.1/

    Greetings,
    Roli

    3 people found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,926 Reputation points Volunteer Moderator
    2022-11-29T21:35:33.083+00:00

    it looks like you are using the new two project template (rather than embedded template)

    it looks like the frontend is the angular default:

    https://localhost:4200 (s/b in the frontend launch settings)

    it looks like the backend is

    https://localhost:7237 (s/b in the backend launch settings)

    I use react, but angular must be similar. in the reverse proxy setting for the frontend must match the backend (probably set to https://localhost:5001)

    https://angular.io/guide/build

    be sure you have multi project startup. right click on solution -> properties, select multi-project, start both.

    you might change the backend to the default 5001 to match the proxy settings


  2. Portscher, Ed 21 Reputation points
    2022-12-20T21:29:20.897+00:00

    So how do you get this to work without downgrading node version. I don't see that as a viable solution. You cant run on node 16 forever. Anyone have a solution?


  3. Doug Clutter 15 Reputation points
    2023-04-19T14:17:41.3533333+00:00

    Just tried updating to node 18.16.0 LTS and VS 2022 17.5.4 hangs as described above:

    • Selected two projects as startup: an esproj project with an Angular 15 app and a csproj project with a .NET Core 7 API app
    • Get the "Deploy Started" message in the Output/Build window
    • A cmd window is spawned and npm start is successfully launched and the Angular app begins listening on the expected port
    • The csproj project never starts Tried the following things which did not work:
    • Checked to be sure node --version reported the correct version both from CMD window and from Open Terminal window in VS
    • Checked to be sure npm --version reported the correct version in same Terminal window. It reported 8.x, so I ran npm install -g npm which installed 9.x
    • In VS/Tools/Options/Projects and Solutions/Web Package Management/External Web Tools added the path to node (C:\Program Files\nodejs) to the top of the list. Uninstalled node 18.16.0, then installed node 16.16.0 from https://nodejs.org/en/blog/release/v16.16.0.
      Now, it works. (sigh)
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.