Adventures in .NET Software Craftsmanship!

I am in the process of getting back from the Build 2011 conference in Anaheim, California where I got to see a ton of stuff related to Windows 8 development and designing Metro style application, and I shall blog a bit on the topic after I have had a good chance to digest all the information. But right now, I just want to showcase one of the coolest new features of ASP.NET 4.5 “Bundling and Minimization of JavaScript and CSS”.

Now for those of you not familiar with the benefits of bundling and minimizing your JavaScript and CSS files, lets just say that reducing the number and raw size of web requests a browser needs to make to interact with your server is going to make your application faster. A faster web application in most internet business scenarios equals more clients equals more money ( faster = more clients = more money).

So you might be asking yourself how complicated is it to setup Bundling and Minimizing of JavaScript and CSS in an ASP.NET 4.5 web application, and the short answer is, not hard at all. You can setup bundling and minimizing in your Global.asax Application_Start to define what to bundle (See following snippet).

I have been using Spark (http://www.sparkviewengine.com) as my default view engine for the past 5 or 6 months and I love everything about it. I like its elegance, simplicity and I depend on some of its features to be efficient in doing most of my daily tasks. That being said, there is a new kid on the block and his name is Razor. Razor, will be an out of the box alternative for the ASP.NET WebForm’s view engine for ASP.NET MVC3 (Read Scott Guthrie’s blog on the topic here). I don’t intend to write a full blown tutorial on Razor, but as I learn the basics for this alternative view engine, I will try to write some “Learning Razor” posts that relate my experience in learning this new technology.

Writing an Inline Recursive Html Helper

The Spark view engine provides you with the ability to define inline macros that allow for recursive calls (Read Louis DeJardin blog on the topic here, and additional documentation here). These macros are extremely useful for rendering a hierarchical structure such as the one in the following snippet.

Now, the Razor view engine allows you to easily build a hierarchical structure by the use of inline HTML helpers that can be called recursively. The following is a basic snippet of a “Hello World” inline HTML helper, and a call to trigger its functionality.

A comment was made on one of my previous blogs requesting additional functionality for the extension method I wrote in April for testing controller action’s that rely on MVC2 Model Validation. The request was simple, to be able to test class level validation attributes such as the ones found on the ChangePasswordModel in the default MVC2 project template. Well, as requested!

The following is the download link for the demo code and slides for my presentation on MVC Extensibility done at the Central Maryland Association of .NET Professionals Code Camp (CMAP Code Camp). Thanks to all who attended my presentation, it was extremely fun plowing through a ton of code all across the stack of the ASP.NET MVC Framework request execution lifecycle.

As promised, and in record time, the code and slides for my presentation on NHibernate 3.0 Alpha are now available for download. As usual, I would like to express my thanks to Justin Etheredge and Kevin Hazzard for hosting and allowing me to present at Richmond Code Camp 2010.2 (http://www.richmondcodecamp.org).

The Author

Currently a Developer Extraordinaire at InfernoRed Technology based out of Northern Virginia. I have been architecting and building software solutions using Microsoft technology for the past 14 years. I was awarded a Microsoft MVP award for C# in 2007,2008 and 2010 and currently an active participant of the Microsoft MVP reConnect program. I am originally from the Dominican Republic, and the proud father of two beautiful daughters that make my life special. You can track me down on twitter (@hernandezrobert) and on this blog at http://www.overridethis.com.