Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

MVP Corner: Use the ASP.NET MVC Framework to Write Web Apps without ViewState or Postbacks

Finally, those who are comfortable with the stateless nature of web programming will be able to develop ASP.NET sites without the insulating layer that ASP.NET has always provided.


advertisement
n October 6, 2007, Scott Guthrie officially unveiled the ASP.NET MVC Framework at the AltNetConf in Austin, TX. It's interesting he chose to present it for the first time at this particular venue because the target audience contained some of the most avid open-source software users including users of the MonoRail MVC framework. What could have been perhaps his most hostile and critical audience turned into happy campers after he presented the details and goals of ASP.NET MVC. Why Model-View-Controller?
ASP.NET has been the odd man out in the web world. While you'll find several MVC frameworks in the Java space, ASP.NET's default model has always been Web Forms. Ruby on Rails framework has captured great fanfare thanks in no small part to its core MVC architecture. For .NET developers, MonoRail has so far been the only MVC alternative to web applications. With all the focus on MVC, one might wonder why? Mode-View-Controller is a mature, proven architecture for the presentation layer. It's applicable in fat client applications as well as web applications. When applied to web applications, the twist is that the controller lives for a single HTTP request and then goes away. Fat client controllers are more stateful and live for the life of the screen, responding to user input.

With Microsoft's announcement of the shift of ASP.NET from Web Forms to MVC, buzz abounds on the blogosphere about how great of an improvement this will be for web applications built on the .NET platform. What's Wrong with Web Forms?
Many developers agree that the Postback and ViewState model employed by Web Forms causes pain and heartache. A quick Google search for "ViewState problem" and "Postback problem" brings back 300,000+ and 400,000+ results, respectively. Scott Guthrie reports that a lot of customers have voiced concerns about the Web Forms model and had requested an MVC framework to simplify web application development. In this author's opinion, the main problem with Web Forms is that it employs an elaborate scheme to hide the developer from the stateless nature of HTTP. With event handlers and the page lifecycle, the developer falls into managing state with ViewState and Postbacks, and when employed in the reality of the stateless web, the model becomes fragile and has problems scaling with complexity.

Goals of the ASP.NET MVC Framework
The MVC framework started as a prototype created on one of Mr. Guthrie's airplane rides. It is still in prototype stage with the hopes of reaching CTP status before the end of 2007. Some of the stated goals of the framework are:

  • Enable clean separation of concerns
  • Be testable by default
  • Support Inversion of Control (IoC) containers and third-party view engines
  • Support customization of URLs
  • Leverage existing ASP.NET features
  • Support static and dynamic languages
With a change in architecture, a few constraints are unavoidable; this author thinks of those as benefits but they mean a change for existing applications, nonetheless:


  • Views will no longer use ViewState.
  • Views will not use Postbacks or Postback events.
Editor's Note: This article was first published in the January/February 2008 issue of CoDe Magazine, and is reprinted here by permission.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap