Today is a great day – the third version of ASP .Net MVC framework was released! Not alone, but accompanied in the today’s developer toolbelt with an assortment of FREE goodies:
- ASP.NET MVC 3
- IIS Express 7.5
- SQL Server Compact Edition 4
- Web Deploy and Web Farm Framework 2.0
- Orchard 1.0
- WebMatrix 1.0
I like this trend in Microsoft’s approach, providing free tools to quickly and cheaply start development, increasing your productivity and making you think about a quick Return of Investment – only your time is involved! But read thoroughly the licence, it might be the case that for using these tools in production or commercially another type of licencing model might be required!
But back to our focus technology!
ASP .Net MVC 3 – what’s inside the box and interest us?
Razor – new view rendering engine, added as a option to the default ASPX one, allowing developers to use a similar style in adding inline code in HTML templates, while discarding the unnecessary characters, allowing us to type more, faster and with less errors than in the ASPX counterpart. The engine features a special syntax, denoting only the start with a common character – the @ – allowing you to write the code without denoting explicitly the end of the code in your markup. The parser is smart enough to understand it and not interrupting your flow of development, mixing code with markup for creation of recurrent lists or tables. Scott Gu has a very interesting introductory tutorial.
jQuery – better integration through the addition in the MVC templates of jQuery UI and the Validator plugin. The last one allows advanced validation scenarios, like decorating the Model with datatype, size, if it is a required parameter, and this will auto-generate the required validation script on the client side. Neat, isn’t it? No more maintaining validation code in several locations!
Output caching – besides the traditional caching on URL-basis and on action method level, now available is also the partial page output caching, enabling the caching of fragments sent ( for example though an AJAX call).
Improved DI – ASP .Net MVC now allows better integration with IOC containers and support for Dependency injection, removing the previous requirement of creation of custom ControllerFactory to just enable this very important scenario. I find it very useful, while the nowadays website rely quite heavily on DI and creating this custom factory becomes annoying when one has to do it for each and every project at least once. A cool addition is that you just register a DI framework and it will not resolve dependencies for your Controllers but also for the others pieces of the MVC puzzle – Action filters, Views, Model Binders, Value/Validation/Model metadata providers.
As we are used now, these aren’t all improvements but also : improved New Project dialog, scaffolding was reworked, cross-cutting filter attributes for Global filters, ViewBag has now the dynamic support of .Net 4 and others.
You can read more from the Hanselman’s and Phil Haack’s articles.