30 Jun 2013 A (not so) little rant on ASP.NET MVC.

I am not very familiar with Windows software and development tools, but I've recently had a chance to change it by using ASP.NET MVC 4 to build a web application. And, unfortunately I might say, it quickly became one of those technologies I do not want to ever use again. Here it comes.

Migrations

It has migrations. That's good. I hate SQL, so I love code first approach. What's not good is that I couldn't find a way to create a migration which create a database, so it has to be (somehow) created beforehand. I also couldn't create another migration without deploying previous one to the server. And when I first tried it, it all ended in a damn strange state where the database were not updated, I had no migration generated and trying to generate one said that there were no changes between the code and the database. But there were. The only way out of this mess that I've found was to revert the database to zero-state and migrate everything again. Not good.

The problem here is that migrations mechanism tries too hard. It tries to keep everything up to date automatically. The database, the migrations, the code. That's not an easy thing to do and have to be carefully crafted. It apparently isn't. A probably better way would be to just create a migration template and let the user fill it in. That is (or a least was when I've last used it) the RoR* approach, seems to work.

Routing

The default routing makes no sense at all and leads to really strange situations. It pretends to be RESTful, yet it isn't, because RESTful is not about removing file extensions and parameters. It is more important that it also makes some sense, right? The default routing can most probably be adjusted to work properly, but there's a better solution. Go to PM console, type

1
PM> Install-Package RestfulRouting

and get on with your life. RoR* rules again here.

SimpleMembership

Now that's just a holy jumping shitball. First of all, nobody seems to know how it really works. Which, by the way, appears to be quite a common thing in the MS™ world.

To give an example, many tutorials actually encourages you to put membership initialization stuff in the layout. What the heck?! Layouts, or Views in general, are not for things that are creating tables in database and setting global variables in our application. Definitely not good.

In general, SimpleMembership was introduced to simplify (yeah, right) the process of adding authentication to your website, while giving you a finer control over what's going on. Well, if that's simple in MS world, I do not even want to hear about not simple. And the whole finer control seems to consist of the ability to use my own database table for non-critical things like Username. All the passwords, OAuth keys and other authentication related stuff are still hidden behind the curtain and good luck to those who want to change them.

Because of that fact, and the fact that MVC uses annotations to provide verification, I still haven't figured any sane way get verification working with SimpleMembership. Not that I care anymore...

Anyway, a link which helped me a bit with my journey through SimpleMembership, might come in handy: http://www.codeguru.com/csharp/.net/net_asp/mvc/using-simplemembership-in-asp.net-mvc-4.htm. There were others too, but they're lost in the abyss.

Some silly randoms

Which makes this whole thing look a bit unprofessional. You know, when you auto-generate a template and it doesn't work? It's because it uses @Scripts/@Styles helpers, which are in the Microsoft.Web.Optimization namespace. And for more confusion, the package for this is named Microsoft.AspNet.Web.Optimization. C'mon MS, make up your mind!

Or when you've added those WebMatrix things for SimpleMembership and they're not there? That's because somebody forgot to switch a flag and you have to manually tell VS to copy appropriate dlls to the output directory.

How to live?

Call for Nancy! A low-ceremony microframework with no unnecessary magic, nor bloat involved. Modelled after the (in)famous Sinatra, delivers some beauty to the .NET world. Or you can always leave this stuff altogether and come with me the NodeJS way.

* Mind that I do not like RoR either.