Moving From Node.js To ASP.NET Core

In late 2014 I made the decision to leave ASP.NET behind and give Node.js a try. Fast forward two years and I am back in my beloved .NET environment but still developing on macOS and able to host on Linux.

Published on Sun, April 02, 2017

Making the move from Web Forms and hosting on Windows to using Node.js and hosting on Linux wasn't a bad idea. I learned a ton of new stuff, came out of my comfort zone and expanded my personal horizon. And at the end of the day it was a lot of fun, too.

But this fun came to an end when I wanted to do something as simple as adding a new XML tag to the RSS feed of my blog earlier this year. Not kidding.

Node.js – Tricky As Soon As It Gets Out Of Your Focus

Node.js – Tricky As Soon As It Gets Out Of Your Focus

Changing the software would require to run it on my local dev machine again. This is still a Mac, but not the same machine I had back in 2014. So I had to set everything up again, which usually has never been a problem in the past with my .NET projects on Windows with Visual Studio ... But here it became surprisingly challenging.

I didn't touch anything important of the software I wrote with Node.js for almost two years. Shortly after my journey to the Node.js land began I had to pause it, because I started focusing on Xamarin – which I am still doing today.

This means I completely ignored the fight between Node.js and io.js, I didn't even update Node on my Linux webserver for two years, nor any of the packages in use. Shame on me, but I don't regret it. This is how things go over time. Focus and interest change and it's not possible to follow up in each area of (past) interest very closely. And hey, my blog ran quite smoothly during those two years.

But not paying attention and not updating to the latest bits for two years didn't make things easier in 2017 either (surprise!). I didn't get the application to run properly with my former setup for two evenings straight. Especially the database driver (I had been using Mongoose and MongoDB) was something I remember to be a bit bitchy.

After uncounted failed attempts including different versions of Node.js (the latest one and the one I was using back in 2014) I started wondering if I wouldn't eventually save time by migrating the whole thing to ASP.NET Core.

Something I would have never had done by day, but hey - there was fancy new tech smiling at me and it was just a pet project. So I did it.

The Migration: Short and Sweet

We had been using ASP.NET Core since late 2015 in my team, but it was the first small project I did by myself with it, and it went surprisingly well.

Looking at the Git history the whole migration took me only 6 evenings. Sure, I dropped the database part completely, but hey. Six evenings to change the whole stack you're working on? That's a nice story.

Maybe it's because Node.js has been a (secret) role model for ASP.NET Core. It's following some well-known ideas and especially the modularity and the concept of pluggable middleware come in very handy.

Here is what has been changed from Node.js to ASP.NET Core:

But two things didn't change:

First of all I didn't touch the front-end besides of moving from Handlebars views to Razor views. I did still use bower, Gulp, Bootstrap etc. for the time of the migration.

In other words: ASP.NET does not stand in your way if you want to use battle-tested front-end tech you know well from other platforms. In fact, quite the opposite is the case – it embraces it.

Secondly I am still deploying directly via Git, which is supported out of the box by Azure so I didn't have to think about it. If I had to I certainly would have been exploring Docker as well. Maybe next time.

Is ASP.NET Core Better Than Node.js?

Is ASP.NET Core better than Node.js?

Of course this is a) a reference to this article I got a lot of feedback for and b) a bullshit question ;-).

Could I have been fixing up this MongoDB mess by trying just for another evening? Maybe. And with investing even 6 more evenings I am sure I had rewritten everything with the latest Node.js bits around and maybe even TypeScript, Webpack etc. So it's not Node.js to blame here but my inability to fix what I have been missing for two years.

On the other hand it's obvious that ASP.NET is in a better shape than it has been two years ago. ASP.NET Core is here, it's – despite all versioning fuck-ups – very mature und stable, it's fast, and it is leveraging all kinds of best practices from other platforms instead of reinventing the wheel the Microsoft way once again.

So if you're wondering whether you should invest in ASP.NET Core or move on: give it a spin!

What do you think?
Drop me a line and let me know!