Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I want to develop and SPA using angular.

Because I have experience in ASP.NET MVC, I have come across a few implementations that use Angular with ASP.NET MVC.

My understanding is that angular routing is run on the client pointing to the html file to open.

However, with MVC, the server routes the requests based on Controller/Action and that returns an cshtml file.

I have seen two implementations for angular routing configuration:

  1. TemplateUrl is the actual html file
  2. TemplateUrl has the form Controller/Action, and controller then returns the cshtml

How does the second work? Is it making a call to the server? How these two compare? Is

share|improve this question
1  
Check this stackoverflow.com/questions/23682203/… – Nitin Varpe Jun 22 '15 at 12:30
1  
To put it simply, there are two routings, controllers, views going on. Client and server. So ASP.NET is concentrating on all Server Side routing, controllers etc. AngularJs is concentrating on all Client Side routing. Both scenarios need to happen independently. However, because AngularJs has partials this does stem the need for cshtml razor generated views. – Callum Linington Jun 22 '15 at 12:32
1  
@RazvanDumitru not strictly true about the routing part. Both client and server can do routing. The server in particular needs to routing so that you can request a certain resource on an API endpoint (this endpoint is where outsiders can access your API). The client can do routing if you want to load up different views when certain actions are perform. So if you want a list of employees, you would have 2 routes, server side for the resource and client side to show the page and display results – Callum Linington Jun 22 '15 at 12:50
1  
No, your last bit of understanding ` On the other hand if angular routes to a view then the server responds with just the html` is not necessarily true. You are right that when AngularJS request these static resources that the server will dish them up, but you can embed these html views into JS and push them into the $templateCache. No you don't need any razor views. Get a really good understanding of gulp, link shows my experiments with gulp, the dist folder shows both stages of gulp building – Callum Linington Jun 22 '15 at 14:19
1  
All you need to use is ASP.NET Web Api and AngularJS. Remember that ASP.NET sits on a web server, so you can just create your index.html and that will always be loaded up first. If you're doing mobile dev I would assume loading all the partials first would be a bad idea, I would just let AngularJS load them from the server when needed. – Callum Linington Jun 23 '15 at 7:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.