BusinessRx Community

Dedicated to the advancement of software, technology and the people who devote their lives to it.

Welcome to BusinessRx Community Sign in | Join | Help
in Search

BusinessRx Reading List

These blog entries are written by industry experts and leaders. We consider this content to be a good read for any software developer or web technologist.

New Lounge Front-end (now with ASP.NET MVC and NHaml)

Since taking over The Lounge I have been slowly refactoring it to my liking. Not that there was much wrong with it, but like most developers I am pretty opinionated in how I think something should be built. Most of what I have done has been in an effort to make a total rewrite of the front-end easier. The biggest change was refactoring the front-end and models to move as much logic as possible to the models and wrap tests around those models. I consider this a good practice and since I knew I wanted to re-write the front-end it was doubly important.

When it came time to start the rewrite I decided to go with ASP.NET MVC, even though it's in an early stage I couldn't imagine writing classic ASP.NET if I could do anything to avoid it. I also decided to go with NHaml for the UI to stay away from .aspx completely and because I am a big fan of the original Haml.

The re-write went very smooth and the site is now live, I know I am not the first site to go live with ASP.NET MVC, but it has to be at least one of the first ones. Especially one of the first ones that is an actual business and not just an experiment. I only ran into a couple issues along the way and they were easy to figure out.

The simplicity of these two technologies is a joy, for instance here is the controller action for showing a room:

public void Show(string id)
{
  Room room = Room.GetRoomByCode(id);
  
  room.LoadVIPs();

  RenderView("show", room);
}

Thats about as simple as you get. (next version we will be able to drop the "show" in the RenderView, even better!)

Here is a excerpt from the view:

    -foreach(TheLounge.Model.Vip vip in ViewData.Vips)
      #roomdetail
        %a{href=vip.Url,class="borderit"}      
          %img{src="../Content/images/vip/" + vip.Image, class="left"}
        .viptitle
          %a{href=vip.Url}
            = vip.Title
        .vipdesc
          = vip.Bio
        .clearleft

I love it. No controls, no viewstate, just simple web programming.

I am going to post a number of posts on things I learned about MVC and nHaml, especially about some best practices I learned in rails that I think apply very well to MVC.

-James

Published Wednesday, April 30, 2008 7:26 PM by Infozerk Inc.: averyBlog
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems
'