Create a .NET Core Single Page App (SPA) with Reactjs, the Microsoft way
Developer environment
How to create a SPA using the latest version of .NET Core SDK for a developer environment, modifications might be necessary for production
Pre-requisites
Install .NET Core (instructions)
Install nodejs (instructions)
Create a folder for your app.
mkdir -p ~/src/mySpa cd ~/src/mySpa
Create and start the app
dotnet new react dotnet run
Verify that it works
When you execute dotnet run on .NET core 2.1.301 one should see messages similar to these:
Now listening on: https://localhost:5001 Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down. info: Microsoft.AspNetCore.SpaServices[0] > [email protected] start /home/t-expertz/src/mySpa/ClientApp > rimraf ./build && react-scripts start Starting the development server... info: Microsoft.AspNetCore.SpaServices[0] Compiled successfully! info: Microsoft.AspNetCore.SpaServices[0] You can now view mySpa in the browser. info: Microsoft.AspNetCore.SpaServices[0] Local: http://localhost:33333/
So go ahead and open http://localhost:5000 on your browser. Then your browser should redirect to https://localhost:5001.
Be advised that the port for Microsoft.AspNetCore.SpaServices[0] will change every time you execute dotnet run.
You might get a message saying that your connection isn't secure when you are redirected to http://localhost:5001. If that happens you can add an exception for that address and continue.
Two optional additional checks you can do:
open http://localhost:33333
the port here should be the same listed in Microsoft.AspNetCore.SpaServices[0]
open https://localhost:5001/api/SampleData/WeatherForecasts
you should see some dates, temperatures and summaries









