I have developed an Angular 5 app with plenty of moving parts (Services, Bootstrap, Angular Material, internal+external JS scripts, etc). Now I want to add database connectivity to this app as well (MS SQL Server only). The app has been developed in Visual Studio Code.
I am following this tutorial from MSDN in order to learn how to connect this app with an SQL Server database. I believe I'll need Web API and .NET Core support for connectivity, and I can't find out a way to do that without starting from scratch in either of the VS Code (e.g. here) or Visual Studio (like in the referenced article) since almost all the articles/tutorials I could find on the topic begin from scratch. The way I see it, creating a new Angular + Core project in Visual Studio and migrating the app logic there file-by-file is not a feasible solution for me.
My questions are:
The idea is that you can't "publish" the API and the Angular app on the same port, but you can use a proxy to connect from the Angular app to the API on the other port. Update: sorry for not answering this long time ago. To deal with the cors issue (in this case) you can use a proxy with the ng serve command.
Using Angular Development with C#They are both easy to use and have great communities and support. Consider this effective combination for your next web development project.
I propose you to create a separate project which contains the REST-Endpoint with ASP.NET Core.
Here you find a simple tutorial:
https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api
With this solution your server is decoupled from client. Maybe in future you like to use something other than angular or you like to create an other client (for example a native mobile app). In this case you do not have to change your server project.
(In the case you are working with visual studio take a look to the projecttemplate. There is every thing you need.
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