0

We are re-writing some of our web applications from asp.net MVC + jquery and angular in some places to asp.net web api (for now it's asp.net 4.6, but future plan is to have asp.net core here) + angular js. The main reason for rewriting is that we don't want html rendering on server side.

Now, some people want to have a NodeJS in between web api and angular js and some people cannot see any reason for having it (including me), it could be that no reasons are seen because of lack of knowledge about NodeJS, but my thoughts are:

  1. If we have angular js + web api, why would we want to have something in between like a proxy (which is NodeJS in this case), and go through that proxy instead of going directly to web api? Is there any scenarios that cannot be done without node js in between which can be done with only web api? Our applications are simple: fetch some data from api and present it in ui. Some authentication is involved as well.

  2. When having backend technology, one is enough, having two (web api and node) at the same time just adds complexity to application and is harder to maintan?

Should we or should we not use node in this case? Having in mind that in the team we do not have a lot of experience with NodeJS, but I hear these arguments that node is very easy to learn, so that's not a big problem.

5
  • Node.js for the sake of node.js isn't an answer! Unless you have a long-term goal of moving your backend from .NET over to node, then I seriously doubt implementing such a thing is worth your time or effort. Commented Aug 14, 2016 at 9:43
  • I'd recommend updating this a little to ask some direct questions, since right now it is in danger of being closed as unclear. Commented Aug 14, 2016 at 10:28
  • Thanks, I've updated it Commented Aug 14, 2016 at 10:49
  • 1. Not sure what's 'web api' here. Is it REST api? How comes that there is 'html rendering on server side' then? It's not clear what should be the role of Node here. 2. It depends. If you want to render the same portions of the app on server side and still use them as SPA on client side, this will likely be a PITA. Using Angular for certain portions of page (widgets) as temporary solution probably won't. Commented Aug 14, 2016 at 13:25
  • ASP.NET MVC - rendering on server side. We want to get rid of rendering on server side (get rid of ASP.NET MVC) and render html only on client (javascript + ASP.NET Web API (REST)). Though there are suggestions to use not only javascript + ASP.NET Web API, but also add NodeJS in the middle between client and ASP.NET Web API. The question is what are the benefits of having NodeJS here:) Commented Aug 14, 2016 at 13:39

1 Answer 1

2

This is not so much an answer as an extended comment because there isn't an outright question here.

Ultimately it depends on what the reason for wanting to use NodeJS are. To address your thoughts:

Why would you want a proxy

  • There are a couple of reasons for having a proxy, such as security and scalabilty.
  • For example, suppose you wanted to have your back-end implemented as a series of Micro services. Without a proxy, the client-side has to know about all of these service's endpoints to it can talk to them. This is exposing them to the outside world which might not be desirable from a security standpoint.
  • It also makes the client-side more complex since it now has to co-ordinate calls to the different services and you'll have to deal with things like CORS on the back-end; having the client side call a single proxy, that also acts as a coordinator, so it can "fan out" the various calls to the back-end services, tends to be simpler.
  • It allows you to scale them independently; some services might need to be scaled more than others depending on how heavily they are used. But the client-side is still hitting a single endpoint so it's much easier to manage.

Why multiple back-end technologies is not necessarily a bad thing

  • Having two or more back-end technologies is a trade-off; yes it can increase the complexity of the system, and can be more difficult to maintain, but it can also make it much easier to implement certain functionality where one technology is better at doing X than another.
  • For example, there are many NodeJS modules that do X, Y or Z which may be more accessible to you than corresponding functionality written in C# (I'm deliberately not going to list any examples here to avoid muddying the waters).
  • If you have Javascript developers who want to get involved with the back-end, they might feel more comfortable working with NodeJs rather than having to ramp up on C#/ASP.NET thus making them (initially anyway) more productive.
  • I find NodeJS really useful for quickly knocking up prototype services so that you can test how they are consumed, etc. Using something like HapiJS, you can have a simple HTTP API up and running with just Notepad in a few minutes. This can be really useful when you're in a hurry :)
  • If you take the proxy / microservices approach, you can stop worrying too much about what technology is used to implement each service, as long as it supports a common communication protocol (HTTP, Message Queues, etc) within the system.

Ultimately, you need to have conversations about this with your team.

  • You haven't mentioned if this is something that your peers are pushing for or if this is a decision being pushed by technical leadership; I would take the view that as the incumbent, any new technology needs to prove that there is a good reason for its adoption, but YMMV since this may be a decision that's out of your hands.

  • My personal recommendation in this case is, don't use NodeJS for the proxy; use ASP.NET WebAPI instead but look hard at your system and try to find ways to split it out into Micro-like services. This lets you keep things simpler in terms of ecosystem, but also clears the way to let you introduce NodeJS for some parts of the application where it has been proven that it is a better tool for the job than .Net. That way everyone is happy :)

  • There is a very good breakdown comparison here which can be used as part of the discussion, the benchmark included in it is a little old but it shows that there is not that much of a difference performance wise.

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

2 Comments

Thanks for comment. Having node is something that is pushed by my peers, not by technical leadership. Since in team we have almost no experience in node js (though there are arguments that it's easy to learn it) and our existing applications with angular js + web api are far away from being perfect - there are still a lot of improvements to be done there, I'm afraid that by starting using node only more chaos will be created. Also, we have back end developers that work only with asp.net and frond end developers that work only with javascript, who would do the node js part is this case.
In that case I'd push to keep asp.net as the "core" part of the system, get it into good shape, and then you can gradually introduce nodeJS for use in some of the less critical parts, so that you can try it out and see how it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.