after stuck in Asp.Net MVC and JQuery for around 4 years I want to go further and switch to .net Core 2, WebAPI and React.
So I have learned through a bunch of howtos and tutorials but what makes me wonder is why every tutorial tells you to add the react just into the WebAPI Project in vs2017?
Isn't it a better way to make a project for WebAPI and a single new project for React (just a folder in the solution e.g. and work with vs code here?)
Why / why not?
I would separate into 2 separate projects. APIs are meant for re-use even if to start you will be building your API for a specific front-end.
Create 2 projects and repositories. They will also likely be deployed independently, your WebAPI will be hosted in a .NET environment whilst you can host your React app literally anywhere.
For sure splitting them into 2 different projects.
API:
Use WebAPI on visual studio as a separate project, bind your project on a fixed port in IIS.
REACT:
Use ReactJS with VS CODE as a new project, and let it work with that localhost:PORT you defined on IIS.
When deploying to production, you can use a windows server to run BOTH of them on IIS. One different site as the API (then you can point api.DOMAIN.com on your domain) and another on the same IIS server that will run your client code (www.DOMAIN.com) or you can setup NODE to run it on windows, but then you'll need some more work to make it work for a production environment.
Personally I wouldn't do that and I would run the react app on Apache or NGINX. And if it's not a large scale website, you can just use Heroku for deployment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With