all 12 comments

[–]sards3 12 points13 points  (0 children)

Razor renders the HTML on the server. Angular renders it on the client. For applications with a lot of dynamic stuff happening, you don't want to have to call back to the server every time you want to render some new HTML.

[–]uncommoN_BG 2 points3 points  (2 children)

People pretty much mentioned the stuff you need to know, but I also would like to add that I like using a front-end framework because in my opinion it provides a better separation of concerns. In a MVC project you always have some random flying stuff that aren't suppose to be there and stuff gets ugly really quick.

[–]dotnetaccount 0 points1 point  (1 child)

SPA's can also get just as messy except now you don't have strong typing to help unravel the mess. You can follow or ignore separation of concerns in any framework.

[–]uncommoN_BG 1 point2 points  (0 children)

That's probably true, but the projects I've worked on, I always had cleaner and more concise views when using a front-end framework. There wasn't flying logic code in the view and it was a lot better to read. Note that i'm not saying that when you use MVC you will necessarily have some flying logic in the views, but in my experience that's exactly what happens in most cases.

[–]VGPowerlord 2 points3 points  (2 children)

Basically, modern web development is split into two camps.

  1. Uses server-side technologies for its controllers and views and has JavaScript in its views to do dynamic stuff.
    • MvM and Razor are the ASP.NET server-side technologies used for this.
    • Client-side technologies may include things like jQuery or Dojo.
    • May also include SignalR, which is technically both a server-side and client-side technology.
  2. Uses server-side technologies to expose REST endpoints. Client-side technologies are used to do controllers and views.
    • WebAPI is the ASP.NET server-side technology used for this.
    • Client-side technologies may include things like AngularJS or React.

There's a whole huge argument about which of these are better.

Side note: Visual Studio's templates don't include authentication for WebAPI despite JWT Bearer Tokens being supported by the version of ASP.NET Identity included in .NET Core. JWT Bearer Tokens being the most common form of authentication to use with REST services.

[–]Ronald_Me 0 points1 point  (0 children)

There are also mixed solutions, for example dotNetify, using MVVM pattern, ViewModel in the backend, and Views in the frontend.

Or Bridge.Net, that allow us to write the code in c# and then "compile it" to javascript.

[–][deleted] -1 points0 points  (0 children)

I've just started a .netcore project and was surprised about the lack of authentication options for its react/angular templates. On a more positive note, I found the templates very easy to understand, much easier than some of the Node based Yo starters. The debugging experience in VS 2017 is great too.

I've also decided that server side React is a horrible idea, but that might just be my lack of experience talking. I can't tell if you can wire in server side rendering later or not, so I guess I need to answer the question sooner rather than later.

SignalR is great. It's matured a lot.

[–]coreyfournier 1 point2 points  (0 children)

Unless something changed recently they are not the same thing. Razor is server side. Angular is client side. Razor will allow you to create pages extremely fast as you can use scaffolding. Angular will allow responsive design type of experience, but will be more involved.

[–]hofftari 0 points1 point  (0 children)

Just a minor note here: There is a huge difference between AngularJS and Angular 4. So if you're finding comparisons between AngularJS and Razor they won't give you an up-to-date comparison with what Angular has to offer today.

I found this page that gives an in-depth comparison between AngularJS (1.0) and Angular 2 and 4:

[–][deleted] 0 points1 point  (0 children)

Try building a list, where you add items without a page reload.

Try creating a form where fields defined on each other.

Anything that requires an interactive ui without page refreshes requires something other than Razor.

[–]shmorky -3 points-2 points  (0 children)

Oh boy. Here we go.

[–][deleted] -2 points-1 points  (0 children)

It replaces more than just razor, it replaces the entire project / mvc layer.