Answer the question
In order to leave comments, you need to log in
How to link Angular front-end and asp.net core back-end?
I heard a lot that they use angular for the front and asp.net core for the back. How is the data transmitted? I suspect that requests for asp.net web api are thrown from the front? Is this the only way?
Thank you!
PS. I know that the studio has a ready-made template, but this does not fit.
Answer the question
In order to leave comments, you need to log in
MS specifically muddied the waters trying to adapt to its framework for SPA.
Think differently.
If you need a web application, a web application consists of two parts (at least) - front and back.
The front is a mountain of scripts that the user receives from a static web server. Back - logic that can communicate with the database and responds according to the protocol available to the front.
Since asp.net is such a large enterprise thing, then the framework for the MS front was chosen as a large, enterprise - Angular and tried to integrate with it as best they could. (It is strange that the MS did not find another fatal flaw and did not undertake to cut its own web frame)
Thanks to them, of course, but in fact these are two different relatively independent applications anyway and you will not find anything about asp.net in the Angular dock.
And getting back to the point, yes, the front makes http requests to the back. Asynchronous requests in both directions are also possible, via websocket.
REST
As for the studio, they don't have much. It is much more convenient to keep a separate project for the client in Visual Studio Code.
And run the api project itselfdotnet watch run
1. Create an ASP.NET.CORE application as a Web.API. No ANGULAR is needed there. This is a separate project in Visual Studio . It can communicate with a MySQL database and run under Linux. I am using a VPS server with UBUNTU
2. In Visual Studio Code create a separate project via Angular CLI.
3. These are two separate independent projects.
On the client, I use ng-swagger-gen. It automatically generates all access services from the client to the server side.
In the back (in the ASP.NET.CORE project), connect the Swashbuckle.AspNetCore libraries
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
Swagger website
https://swagger.io/
ASP.NET.Core Documentation - Swagger
https://docs.microsoft.com/en-us/aspnet/core/tutor...
You make changes on the server in controllers. On the client, you start the generator and all access services are automatically updated.
The backend can be accessed from anywhere (not just from the Angular project). You can, for example, from a Windows application written in any language or from any framework ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question