Knowledge is power. We love to share it.

News related to Mono products, services and latest developments in our community.

denis

ASP.NET MVC

12/19/2008 By denis 0
Rated 1.00, 2 vote(s). 
Bookmark and Share
There's been a lot of talk about the new ASP.NET MVC (Model View Controller) framework and its interoperability with the "standard" Web form applications like MonoX. MVC approach brings a lot of neat features to ASP.NET developers:
  • it gives you a total control over the rendered HTML (no client-side ID pollution and similar by-products of the Web form approach)
  • it provides clean separation of concerns
  • it enables test driven development (TDD). Web forms and TDD were not a really happy couple, since Web form (aspx) code is running inside the ASP.NET worker process. Your pages need access to the HTTPContext, the Request and Response objects, and everything else that ASP.NET provides them at runtime
  • search engine-friendly URLs (in MVC you don't have to have a physical server file for every URL)
  • easy integration with javascript frameworks
  • absence of ViewState and PostBacks


We are aware that many of ASP.NET developers will not really appreciate the last feature. After all, ViewState and Postback events were at the very centre of the ASP.NET programming model for almost a decade. In my opinion, while it was certainly useful to use the same mental model of development for both Web and desktop environments, this approach was rather clumsy and produced many side-effects. On the other hand, MVC will have its share of problems, especially in this early stage. ASP.NET MVC views are rather hard to read beacuse of the tag soup we thought was left in the good old classic ASP days. While the separation of concerns is a very good thing, the separation of the HTML markup and the inline code cannot be completely disregarded as a non issue. Due to the vast marketplace of powerful ASP.NET controls that are available today, many of the developers we know will have a tough time switching to the "use foreach loop instead of the repeater" mentality. Although this can look rather extreme, there are a few techniques for RAD-style MVC development: using lambdas, MVC UI Helpers, custom view engines,... Additionally, many of the major control development companies already announced MVC versions of their products.

In any case, we love the MVC framework and are starting to use it in our MonoX-based projects. Scott Hanselman recently published an excellent article on using Web Forms and MVC side-by-side in your projects. For those of you that feel that routing rules should never go to the compiled code file, Jonathan Holland built a MVC RouteBuilder HTTP module that allows you to move all routes to the web.config file. We encourage you to give MVC a try - please let us know if you need any additional help with it.
Tags: