4. Run and debug
Start both halves with one keypress, then debug C# and JavaScript together.
Start the app
Select the https launch profile for the server project and press F5. Two console windows open:
- The ASP.NET Core API server.
- The Vite dev server, showing a "ready" message with its local URL.
The browser opens on the Vite URL. Edit a React file, save, and the page updates without a full reload.
Run from the command line
dotnet run --project ReactWithAspNet.Server --launch-profile https
Stop the browser opening on the API URL
By default Visual Studio may open the server's own URL (often showing raw JSON). In the server project's Properties → Debug → Open debug launch profiles UI, clear Launch browser for the https profile so only the Vite URL opens.
Debugging
- C#: set breakpoints in controllers or endpoints as usual.
- JavaScript/TypeScript: use the browser's developer tools (F12), or enable JavaScript debugging in Visual Studio's debug settings to hit breakpoints in
.jsxfiles. - React DevTools: install the browser extension to inspect component state and props.
Managing npm packages
- Right-click the npm node under the client project to install or update packages, or use a terminal in the client folder.
- From a terminal:
npm install react-router-dom.
Front-end tests
The JavaScript project system can discover tests written for frameworks such as Jest or Vitest and show them in Test Explorer. Check the client project's properties and your package.json scripts for how your template version is configured.
Multiple startup projects
If you prefer running the pieces separately, right-click the solution, choose Configure Startup Projects, and start both the server and client projects.