Home > Back-end >  I have created an ASP.NET Core Web API with Visual Studio but the front-end is in Angular. How can I
I have created an ASP.NET Core Web API with Visual Studio but the front-end is in Angular. How can I

Time:12-21

The problem is how I can configure the Angular application while my backend work which is an ASP.NET Core Web API, created in Visual Studio and the frontend is Angular created in Visual Studio Code and just want to run the application but don't know how.

CodePudding user response:

'dotnet run' should work. This launches the ASP.NET Core app and it ng serve's Angular. It runs on port 5000 as default (Kestrel). Or use IIS/IIS Express when using VS as an IDE instead.

Also, you may run into a timeoutException. This is a known bug when using Angular with ASP.NET Core. There is a workaround

CodePudding user response:

You need to link both front end and back end using HttpClient module in angular.

import { HttpClient } from '@angular/common/http';

and in service file you need to specify the path for respective http requests which will call the backend code in Web API.

  • Related