First Impressions of ASP.NET MVC
Posted By: nicocrm on November 4th, 2008 in Uncategorized
No Gravatar

I finally got to take a look at ASP.NET MVC today for a small project (a basic lead capture kind of functionality).  It is a real breath of fresh air compared to web forms – all you have is very straightforward HTTP.  It also offers a very good separation between the UI and the application logic, and writing Javascript is a lot easier without having to worry about UpdatePanel’s and mangled control ids.  One of my favorite features is the data binding.  A few times I have banged my head against the ASP.NET web form data binding without finding a very satisfying answer.  ASP.NET MVC makes it amazingly easy – instead of having code like the following:

<asp:TextBox runat="server" id="txtLastName"/>
Contact c = new Contact();
c.LastName = txtLastName.Text;
// ...

You’ll have:

<input type="text" name="contact.LastName"/>

and a “controller” function taking a Contact object as parameter:

ActionResult SaveContact(Contact c){
// ...

There are a few variations of course but the basic case is very simple.  To use webform databinding in this case you may have to use a FormView, create the various templates, create and configure the DataSource, etc – what a headache.

Still, this is no Django.  The modularity of Django in particular is far ahead and an ASP.NET MVC application seems very “monolithic” in nature.  This is one area where webforms (with user controls and custom controls) are actually good.  The route configuration is not very elegant (compared to Django).  The documentation is poor, and the API still appears to be very unstable (I don’t mean that as buggy – just that it is mutating very fast).

I would probably use it again on a blank slate project, and I think it will get better with time.

Leave a Reply