I am having trouble understanding the purpose of everything I am trying to do here. I have web api, mvc, and angular2 project linked by authentication provided by identityserver4

As in, why would I make a web api?

Does the user that connects to my MVC application communicate for information directly with the WEB API and not the MVC backend?

If so what is the purpose of the MVC backend if I am aiming for a SPA with angular2?

With Identityserver4 I've already connected the MVC and the WEB api and the users together. Does that mean from that moment on after login and 1st page load the majority of the calls for information comes from the web api not the MVC backend?

If you guys can clear up on what exactly the purpose of the MVC backend and the web api and how that relates to a SPA with identityserver integrated it would be helpful!


  • 1
    What "MVC backend" are you referring to, exactly? – Robert Harvey Feb 13 '17 at 20:44
  • Well the one that simply hosts the angular2 application. – Ya Wang Feb 13 '17 at 20:45
  • Angular2 lives in the browser. It's not a backend at all, nor is it MVC; it's MVVM. – Robert Harvey Feb 13 '17 at 20:45
  • I already have angular2 siting on a .net core application which is structured as a MVC Application. Yes angular2 is not back end at all but it can communicate to the backend for data to consume for user viewing. My question really lies in where angular2 should be getting data from the MVC application or the web api that it is associated with via identityserver – Ya Wang Feb 13 '17 at 20:48
  • I'm going to go with "from the Web API." The web API is responsible for feeding data to Angular2. If there is an MVC application at work here, its role is almost certainly to provide a "core" web page scaffolding where Angular2 can live (ergo, "Single-Page Application"). – Robert Harvey Feb 13 '17 at 20:50

In front-end projects (regardless of .NET), it is common to run a "dev" web server to host the files for testing/debugging. It sounds like the MVC project is just performing this function for the Angular2 files.

You could use MVC controllers as your API back-end, but that is not the standard way to utilize ASP.NET's MVC paradigm. You probably want to use the Web API project, since it is designed for that purpose.

You didn't state which grant type you are using with IdentityServer4. But note that you should use the Implicit Grant for browser apps. Other grants require the app to have (or collect) sensitive information. With Implicit Grant, credentials do not pass through the app. Instead, when the app does not have an access token, it redirects to IdentityServer for login, then IdSrv redirects back to your (i.e. Angular2) app with an access token. Then your app sends the access token along with every API request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.