Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular app, Inside an Asp.Net Core Project, pros & cons

I would like to create a Single Page Web App with Angular but I couldn't decide to project type. (Just generated files by tools like angular-cli or that generated files inside an Asp.Net Core Project)

I got some question.

  • What are the advantages and disadvantages of building angular app on ASP.NET Core Project?

  • Which cases I should prefer to locate angular app inside a ASP.NET Core Project?

like image 862
SLYN Avatar asked Aug 01 '17 21:08

SLYN


People also ask

Can we use Angular with ASP.NET Core?

The updated Angular project template provides a convenient starting point for ASP.NET Core apps using Angular and the Angular CLI to implement a rich, client-side user interface (UI). The 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.

How does Angular project integrate with NET Core?

To use publish, create your JavaScript project using Visual Studio 2022 version 17.3 or later. In Solution Explorer, right-click the ASP.NET Core project and choose Add > Project Reference. Select the Angular project and choose OK. Right-click the ASP.NET Core project in Solution Explorer and choose Unload Project.

Can I use Angular with C#?

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.


1 Answers

I'd like to take a stab at this. I'll agree that the answer is on some part opinion based though.

I have just been comparing the two versions for a new project that I am involved in.

First some facts

  • The Angular project created inside of the ASP.Net core application is in no way dependant on the .Net code. You can navigate to the directory and type ng serve and run it by itself.

  • You can copy the angular code to another directory or repo and host it by itself if you for some reason later on decide that you don't want to combine it. All you have to do is copy paste the angular code, and then remove some lines in startup.cs regarding the internal hosting.

  • The code that gets added inside of the asp net core template is close to the base angular app with a few examples added on.

  • If you use the login functionality template it implements an oidc client, and an identity server on the back end, (opinion) pretty much the same way I would have done it myself. There is nothing stopping you from rewriting it if you don't like it. At worst it's a good example of how it can be done.

  • As of today the template is using Angular 8.0.0, you can just change the package.json to get the latest version and run npm install. It works great.

  • You can still use Visual Studio Code for the Angular parts with a combined project.

Here are when Id choose the different versions (warning opinions ahead).

When to choose the asp.net core angular project.

  • Small web app with limited functionality.
  • Small team, probably same person writing angular code as api code.
  • If you are unsure. You can always split later.

When to choose separate apps.

  • Big team with deployment builds and automation.
  • If you want to host angular and asp.net core separately (for reasons such as to achieve maximum performance and load balancing in apps with thousands of visitors).
  • Separate people coding angular and asp.net
  • You don't like having it all in same repo and want to split it up.
  • In a bigger teams and contexts with multiple APIs you will probably have to deal with CORS anyways, but if not you will have to at least think about it for this to work.
  • If you are unsure, you can always combine it to one app later.
like image 65
JensB Avatar answered Oct 13 '22 13:10

JensB