Fun! Fun! Fun! With ASP.NET MVC View Engines
by Jon Stonecash
Thu, Oct 01, 2009
Room:
Time:
0:00
ASP.Net MVC (Model View Controller) is one the new shiny technologies from Microsoft. We will take a quick tour of the M, V, and C of MVC. While the Controllers and the Models are very nice, the real fun is with the View Engines. That's right! ASP.NET MVC supports a gaggle of different view engines. We will take a look at a representative set of view engines (ASP.NET, Spark, and NHAML in some detail) and a quick "fly by" of other (NVelocity and Brail). We will look at the good and bad of the coding experience, the debugging experience, and the (dreaded) maintenance experience. All of this will be useful input to the selection of a view engine for your next project.
The secret is that the selection does not have to be exclusive. Fun Fact: you can use multiple view engines in the same application. Funner (OK, Even More Fun) Fact: you can even use multiple view engines on the same web page. Come and see how to make the magic happen. More goodies: see how to write your own view engine for fun and profit; if I told you how easy it was, you might think it was a scam.
But wait! there is more: in our "Bait and Switch" department, you can see how to switch the view that you that you use in order to support mobile browsers. You can even switch view engines on the fly. Learn how to log data for a subset of web pages (determined by values in your application configuration file) by using a different View Engine. Bring up your mastery of this dynamite technique at your next social gathering and see how many admiring glances you get.
And there will be unit testing. Yes, even the HTML produced by a view can be unit tested. Sprinkle a little pixie dust on the view, chant "separation of concerns" three times, and be able to verify that goodness of the incoming model has been transformed into even more wonderful HTML. How cool is that?
About the Author
Jon Stonecash is a senior consultant at Magenic, a Microsoft Gold Partner consulting company. Jon Stonecash has worked in software development for much longer than he would like to admit. In that time Jon has had the opportunity to make most of the serious software development mistakes at least once. He has programmed in over a dozen languages including several different assembly languages, Fortran, COBOL, SNOBOL, classic Visual Basic, VB.NET, and C#. He has survived the structured programming revolution and the object-oriented revolutions (having inexplicably missed out on the sexual revolution). Jon's software development activities have included the development of operating systems, scientific and engineering applications, and enterprise systems. He has worked in every phase of software development from the initial specification of requirements through to customer support. Along the way, he picked up a BS in Mathematics and an MBA. He still has hopes of finding something that he can be reasonably good at. His long term interests center about databases and the aspects of the application that handle data access and business logic. He is also interested in the tools and processes that assist the development process. Jon can be reached at jons@magenic.com . Jon also has an active blog on "Designing Out Loud in the .NET Space" at http://blog.magenic.com/blogs/jons/default.aspx .