S
S
Sitler392019-12-10 13:11:52
Angular
Sitler39, 2019-12-10 13:11:52

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

3 answer(s)
A
Anton Shvets, 2019-12-10
@Sitler39

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.

V
Vladimir Korotenko, 2019-12-10
@firedragon

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 itself
dotnet watch run

@
@atmk, 2020-01-04
_

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 question

Ask a Question

731 491 924 answers to any question