Lachlan B's Blog

Moving from classic ASP to MVC5

So the past few weeks I've been re-writing my website. Previously it was written in Classic ASP (yes, you read that right) and it was running off a Microsoft Access database. Yes, you read that right too.

The code has served me well since I launched in 2006, and can I point out, that was NINE years ago. I have to salute classic ASP for doing a pretty bang up job. The site rarely went down, it was never hacked (apart from a mountain of comment spam) and it was all-in-all, pretty good fun.

But the past couple of years has seen a huge improvement in website coding. It's all so much easier and more fun now, so I figured I might as well rewrite it in ASP.NET and move it to MVC. So here's the full stack of technologies:

  • Bootstrap for the front end - fantastic library once you get your head around it

  • JQuery for the little ajaxed archive box over to the right

  • ASP.NET MVC4 for the back end

  • Entity framework for talking to the DB

  • SQL Server for the DB

The whole thing was coded using Visual Studio community edition and SQL Server express. Half was written on my desktop, and the other half was written on my MacBook air running a windows 7 VM using Parallels - a process that ran surprisingly well. I synced the code between the two machines using Git Gui, another process that ran surprisingly well.

So what's great about the new technology stack and what's not so great?

Friendly URLs - Good

Nice URLs in classic ASP weren't impossible, but they weren't exactly easy. Nice URLs in Webforms was possibly even harder! But in MVC... URLs can be super, super friendly. The routing options are many and super variable, and it's all pretty cool. It's quite fiddly to setup, but it's pretty powerful and very nice. You'll see that each blog entry URL on this site has the format /year/month/title. Easy to setup and makes a lot of sense.

Entity Framework Good

I love the entity framework. For basic CRUD operations it's a life saver. Super easy to setup and use, it's amazing. If you've never had to go down the whole "1 stored proc for each database query" you have no idea just how much time you're saving. For anything more complicated than simple queries I'll be using stored procs (stored procs are ace) but for the basics, Entity Framework is awesome.

Javascript + CSS bundling and minification Good

I love bundling and minifying my javascript and CSS. Your site loads quicker, it uses less bandwidth, it's a win-win. The new bundling and minifying libraries are awesome. Easy to setup and use and do the job perfectly. Great job microsoft.

What's not so great?

Config Files Bad

Haven't we learnt enough from the horror that is Java??? I was super happy to move away from Java 10 years ago. It had become XML configuration file hell. The web.config file is great, but boy can it be over-complicated. On top of that a typical MVC project can have multiple web.config files (mine has 3). As far as I know there's no nice easy to read reference for the web.config file format, and I'm always discovering more undocumented "features" that need to be set. (minFreeMemoryPercentageToActivateService I'm looking at you). Please, Microsoft, continue simplifying the web.config file, not complicating it.

Project Layout Bad

MVC straightjackets you into a particular project layout. You basically have to put your Controllers into /Controllers, your Views into /Views, your javascript into /Scripts, etc etc etc. Now I'm well aware that technically you don't have to, but if you want NuGet to play properly and if you want Visual Studio to play properly, you're going to have to meet it halfway. This is not a lot of fun, especially when the standard layout is pretty, erm, weird. Adding areas to your project just makes it more confusing. Not cool.

NuGet Bad

Ok I'm going out on a limb here. I'm not crazy about NuGet. It does weird things to your project without telling you what it's done. Trying to find the "official" or "right" version of a library is difficult. Trying to figure out dependencies (and dependencies of dependencies) is even more difficult.

Ok end of whinge.

Big thanks to the master of security Troy Hunt for his excellent security scanning tool which I've run the website through.

Are there any other libraries or tools that I should be considering?