TOMMY WANG
TOMMY WANG

Reputation: 1402

angularJS routing in asp.net MVC

I'm newbie in angular so i have two questions on AngularJS routing. Deeply sorry if this has been answered. tried a brief search, didnt find exact match.

  1. I get the idea of SPA, the cost of asp.net server round trip, however, what's a valid real world scenario that make best use of both server side routing and client side routing together? or simply give up the asp.net mvc routing at all?
  2. If partial routing rules defined on both side, isn't it a bit messy?

Upvotes: 0

Views: 415

Answers (2)

pedrommuller
pedrommuller

Reputation: 16066

well, that depends on what you need I saw some people doing a mix of routes between angular and MVC, you can take a look to he boilerplate and hot towel projects for asp.net and angular combo take them as reference, both are like starter kits.

In my personal opinion (and this is subjective), I prefer to use a RESTFul architecture / SPA let angular do the routing and have web API or service stack as a middleware very much like the mean.js approach for me it's a cleaner and more natural for a SPA application.

take a look to this article that talks about rest API and some best practices.

Upvotes: 1

user3204022
user3204022

Reputation: 1

I don't know if there's a perfect answer since it all depends on the project you're working on and the preferences of the dev team. I personally like keeping some of the MVC concepts (mvc views, routing, etc.) and just using angular for a given page's functionality. I don't make use of the angular routing at all. Obviously it would be a different story if you were trying to create a full SPA.

But I find that in a lot of cases (especially if working on an existing app written in MVC) you can introduce bets and pieces of angular without taking it all the way. If you're trying to get rid of page redirects entirely and want a full SPA experience then you should probably use a service approach instead as already suggested (if you want to stay with the Microsoft stack, Web API is a good option).

Upvotes: 0

Related Questions