API vs Angular web application templates in Visual Studio 2019

Viewed 744

I have completed a tutorial where I created an API using .NET core: enter image description here

and then creating a separate Angular project using Angular CLI that I edit in VSCode.

This all works fine but I was wondering how this is different from using the the Angular Template in VS studio:

enter image description here

I understand that this might get downvoted but all I have found on these is how-to tutorials. I would like to understand the pros and cons of each and perhaps where I would use one over the other. The Angular project in Visual Studio allows me to get user authentication right out of the box which is why I'm looking at it.

Just to be clear, I'm looking to understand the differences between

(1) .NET Core Web API + Angular CLI Project
(2) Angular Project Web Application
1 Answers

The Angular project template is equivalent to creating an ASP.NET Core project to act as an API backend and an Angular CLI project to act as a UI. The template offers the convenience of hosting both project types in a single app project. Consequently, the app project can be built and published as a single unit. You can refer to below article :

Use the Angular project template with ASP.NET Core

The big difference is from ASP.NET Core 3.0 or later , the template offers authentication in Single Page Apps (SPAs) using the support for API authorization. ASP.NET Core Identity for authenticating and storing users is combined with IdentityServer for implementing Open ID Connect:

Authentication and authorization for SPAs

In Visual Studio ,choose Angular template -->Change Authentication --> choose Individual User Accounts . Or you can use .NET Core CLI :dotnet new angular -o <output_directory_name> -au Individual

Related