1

Could anybody please help me out regarding how to implement Angular 2 with Asp.Net Web API? Any tutorial link would be helpful.

There is very little to no documentation available in this regard.

I did implement the https://angular.io/docs/js/latest/quickstart.html

But it requires npm start which starts the node server useful for CommonJS module loading. I want to use IIS and Web API. Can I use CommonJS or do I have to use any other module system

enter image description here

If I use CommonJS with IIS development server I get this error:

enter image description here

in the console. The same link works fine when I start using Node server. This means on the production server I have to use Node as well as IIS for Web API? Is there any way I can use Angular 2 only with IIS and possibly eliminate CommonJS if needed. Any tutorial to Angular 2 with Asp.Net would be helpful.

2 Answers2

0

You have to use SystemJS as your module system, if you want to use it exactly like in the tutorial. If you want to use CommonJS, use something like Browserify.

Luka Jacobowitz
  • 22,795
  • 5
  • 39
  • 57
0

You can have a look to following article for Angular 2 and Asp.net MVC with Web API.

https://www.codeproject.com/Articles/1181888/Angular-in-ASP-NET-MVC-Web-API

It's a good one but this article uses Asp.Net MVC in the middle. You might consider to remove Asp.net mvc part and develop a website with Angular(client side) and web api(server side).

This one is a simple example. https://github.com/thinktecture/apisummit-2016-angular2-webapi

On the other hand, if you want to use IIS then you need the build your angular project with ng build --prod and move the dist folder into your IIS website folder. Note that you don't need a node server on IIS because nb build transpiles old the typescript files into javascript and gets the other static files(html, css, js, etc...) and prepares for you to deploy to any web server like IIS.

another sample angular(client side)-Asp.Net Web API(server side) https://www.youtube.com/watch?v=AYgs0kLjTLE

Sam Salim
  • 2,145
  • 22
  • 18