88

I'm currently evaluating the programming model for creating future Webapplications in my company. So I will decide between ASP.NET MVC 5 (with Razor Views) and AngularJS with ASP.NET WebAPI. What are the advantages / disadvantages of these two programming models?

6
  • 5
    Well... if you're going to anchor AngularJS to ASP.NET... you're not really giving it a fair comparison. It's like you're looking to take the Javascript out of Angular, and that's just not the way it's meant to happen. Angular is meant to be your framework for the client, and works best when you use very little server side templating: simple-talk.com/blogs/2013/10/16/…. Things like authentication and such make sense, but leave razor out, and just go straight .NET and create an API layer for Angular with it. Commented Apr 15, 2014 at 7:15
  • 4
    I think what you really need is just AngularJS with ASP.NET WebAPI. I think it has best of both world. I tried mixing MVC with AngularJS and it was not very nice experience when I ran into issues, so would suggest not to get in to that trap. One thing I miss with this approach is the device based views that MVC with Razor engine can provide. There must be a way to overcome this, but I didn't expriment enough yet. Commented May 7, 2014 at 3:39
  • 1
    Having worked with Angular for just a few short months (although it seems like forever), I would never go back to Razor. The more you work with Angular, the more you come to appreciate it - flexibility and power, sometimes it feels like magic. I should say that Web API does not play nicely with Angular, at least on the form POST, but that could be worked out. It is not an easy transition for a C# programmer syntax wise, as javascript is not a strongly typed language. But as you overcome this hurdle, you would come to appreciate Angular. Commented Nov 9, 2015 at 0:14
  • 1
    Razor is a horrible thing even among templating engines. You'll notice a drastic increase in productivity when using angular over any templating engine (Jade, handlebar, razor etc). Use a backend which serves JSONs (can be web-api, node-express or PHP) and a angular front end. And just to note, knockout is not nearly as good as angular.... All the best... Commented Jan 30, 2016 at 19:59
  • 2
    @BrianVanderbusch Not really sure what you're talking about. The backend doesn't matter at all. It could be anything. He's saying he'll use ASP.NET as the backend and angular as the client side front end. Angular still needs to make calls to the server for data. This has nothing to do with not giving Angular a fair comparison. Commented Oct 14, 2016 at 14:24

2 Answers 2

103

My 2 cents. I personally prefer pure HTML views, an entirely angular front end along with a Web API/EF/SQL Server back end, basically no Razor. Razor is an abstraction to help programmers render HTML, these days everyone's coming to the conclusion that removing these abstractions is a better idea, hence the evolution of ASP.NET from web forms, to MVC etc. It's not really difficult for developers to get to grips with HTML and use an angular front end, moreover this makes UI designers jobs easier, they have pure HTML and JSON/Javascript, they don't need to go about understanding MVC, Razor, controllers and actions. We used to work completely on MVC, in our latest project we moved to a Web API back end and an angular front end, and we've noticed that our UI designer's productivity has vastly improved.

Sign up to request clarification or add additional context in comments.

7 Comments

And i'd like to add to that, with angular you get to update your templates dynamically, which is obviously, awesome
Yea, when it comes to developing a more dynamic and responsive front end vs cost of development, there really is no competition.
@user189756 how are you delivering the HTML pages to the client when using the Web API approach?
@Yoav This is an old answer, but at the time it was an MVC host with a Single controller.
@Yoav Precisely. But I'll add that the other answer is also excellent, especially taking things like SEO into account.
|
55

I believe you cannot compare. AngularJS is a Single Page Application (SPA) framework whereas ASP.Net MVC use the standard model where one navigates between pages. Whether you want to build a SPA is decided by factors like

  • Do you want SEO. Which most of these JS rich framework have limited support.
  • How can you structure your app as SPA or multiple SPAs.
  • Coming from a type safe language C# to JavaScript programming is a challenge.
  • Learning AngularJS and using it effectively.

We use the standard MVC 5 razor view to setup the initial AngularJS views so you can even combine them together if required.

See this answer Can you use AngularJS with Parse.com? to derive more context.

10 Comments

"...whereas ASP.Net MVC use the standard model where one navigates between pages." This is simply false. MVC apps - using razor - can be designed as SPA's very easily.
AngularJS is not limited SPAs, you can very well build a multi page website with angular along with with deep linking....
AngularJS is not a SPA. You can use it like a SPA, but that is not automatic or necessary. Have have to add in the routing dependency ng-route in order to even have routing. AngularJS is incredible and can be a great SPA , but its just silly to say AngularJS = SPA.
TypeScript is a good option for type safe js.
AngularJS was made by Google. If it lacks in SEO they are doing something wrong.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.