2

This is a general question. I've seen so many projects where they add the Angular 4 app or Aurelia app or any other front-end framework in the same project of the asp.net web API project.

What are the pros and cons of doing that? If I made it this way customized only for one client. what if I wanted to have a mobile application consume the same restful web API?

Plus it's really hard to integrate angular 4 with asp.net

Note: I'm speaking of ASP.net 4X, not ASP.net Core.

Thanks very much

Willy
  • 1,871
  • 1
  • 16
  • 29

3 Answers3

2

I would strongly suggest strictly split things. There is no benefit in mixing them together except initial feeling safer but its just inertia without a good reason for it. I was in that situation a few months ago, almost mixed it but then decided to go against my current safety feeling and has split them completely. And i am very satisfied with that decision.

Give your project full independent lifes of their own and combine them as needed when needed. You'll get most flexible setup that way.

In particular, that means:

  1. Leave your asp web api as is as you want it fully client agnostic anyway
  2. Have your angular app with angular CLI and all that goes in usual angular development/deployment: cli, webpack, dockers, etc...

You can take a look at this discussion with similar info: Add Angular 4 to an ASP.NETCore Project

PS. It doesn't matter if its asp.net core or not. Its web api, RESTful service that matters and splitting backend & frontend apps.

dee zg
  • 10,582
  • 7
  • 33
  • 59
1
What are the pros and cons of doing that? 

If you have the same team working on both, it actually makes it easier to have to same solution with 2 projects (one for API and other for angular (with CLI if that's the choice) )

Build process can also be easier. We can have same end product.

what if I wanted to have a mobile application consume the same restful web API?

Should not be a problem. You can deploy both in the same virtual directory or create different directories. APIs can still be called since it has its own URL.

Plus it's really hard to integrate angular 4 with asp.net

Yes its a little tricky. You have make tsconfig changes to the project file XML if you are planning to have same project for both (API and angular) since VS completely ignores tsconfig.json file. Also you need be careful about the Typescript version since VS has the tendency to use its own version installed on top of it

Rohit Ramname
  • 784
  • 2
  • 8
  • 22
1

Basically I ALWAYS SPLIT the front end and the back end in 2 SEPARATE solution for many reason:

1 - if you want to scale your app .. you can be more granular (and maybe you scale only your back end ... if you have back end and front end all together you've to scale all)

2 - your back end can serve multiple front end ..as it is a simple WebService endpoint (in RESt if you're using WEBAPI) ..so for example Mobile ..website and so on

3 - if you've to refactoring the front end or the back end in the future it's more simple cause they're not in the same solution ... especially if you want to change technology stack on the back end

4- you Team can develop the front end and back end separately ..

federico scamuzzi
  • 3,346
  • 1
  • 13
  • 21