Skip navigation

Back Draft

 

Shift --> MVC

 

By Jonathan Goodyear

 

Undoubtedly, the biggest news in the world of ASP.NET this past fall was Scott Guthrie s announcement of the Microsoft ASP.NET MVC Framework (http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx). A close second was the announcement that Visual Studio 2008 would be released by the end of November. After a relatively slow summer for new ASP.NET technology out of the Redmond giant, this was all very exciting.

 

For those of you like me who may be acronym-impaired, MVC stands for Model-View-Controller, which is a well established software development pattern that has been around for years. I won t bore you with a tutorial on MVC in general. For that, I ll defer to your favorite search engine (Wikipedia has a concise and informative entry on it at http://en.wikipedia.org/wiki/model-view-controller). The concept of applying MVC to ASP.NET isn t novel, either. The Castle Project s MonoRail platform is just one example of a third-party MVC framework for ASP.NET (http://www.castleproject.org/monorail/). Microsoft is bringing the concept of MVC to the ASP.NET masses, though, with an officially blessed implementation. This is important, because many companies will not allow developers to use tools or platforms that are not officially supported by a corporate entity of some sort. Some of the other advantages of Microsoft s MVC Framework include:

  • Microsoft is creating Visual Studio project templates to support everything that you can do with its MVC Framework.
  • It supports using ASPX, User Controls, and Master Pages for the View part of the pattern. Other MVC frameworks rely on open-source View engines like NVelocity or Brail (which are also, incidentally, both supported by Microsoft s MVC Framework).
  • It supports all the existing ASP.NET providers (think Membership, Roles, Caching, Profiles, etc.).

 

Microsoft s MVC Framework is not all sugar and spice, though. Its very nature forces you to leave many things on the table. For instance:

  • ViewState. This is a crutch that many developers (myself included) rely upon daily to keep track of their Web control state. The more complex your application gets, though, the bigger your ViewState gets (slowing down performance and increasing the chance of it becoming corrupted). We re really better off without it, but going back to the days of not having this is not appealing to me. I m sure Microsoft will have a solution to ease the pain, though.
  • PostBack. Microsoft wanted to make it really easy for Windows developers to move to Web development, and PostBack enables them to create familiar event-driven user experiences. Unfortunately, ASP.NET accomplished this through a hack known as the page lifecycle, which introduces its own set of frustrations.
  • Control variety. Because ViewState and PostBack are not supported by Microsoft s MVC Framework, many of the rich ASP.NET controls you know and love will have limited functionality. Microsoft has announced they will release a set of MVC-compliant controls to complement the existing WebForms controls, but I m sure they will not be releasing a full set all at once. Compound that with the fact that third-party component vendors will need to release updated versions of their own controls. Right now, they re still scrambling to release WPF and Silverlight controls, so they may not have the bandwidth to tackle the MVC load. Eventually, the situation will stabillize but you may end up rolling your own advanced controls (think AJAX) for awhile.

 

Of course, WebForms shouldn t be referenced in the past tense just yet. Microsoft is not discontinuing that Web development paradigm, and, in fact, will still be innovating and enhancing it. You can even use WebForms and MVC in the same Web project, so you can plug in new parts of your Web application using the MVC pattern if it suits your fancy. I m going to be working with some pre-release versions of Microsoft s MVC Framework over the next few months, and will definitely have more to report on. I definitely like what I ve seen so far. Until then, Scott Guthrie has written a pretty good introductory tutorial (http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx).

 

Jonathan Goodyear is president of ASPSOFT (http:// www.aspsoft.com), an Internet consulting firm based in Orlando, FL. Jonathan is Microsoft Regional Director for Florida, an ASP.NET MVP, a Microsoft Certified Solution Developer (MCSD), and co-author of ASP.NET 2.0 MVP Hacks (Wrox). Jonathan also is a contributing editor for asp.netPRO. E-mail him at mailto: [email protected] or through his angryCoder eZine at http:// www.angryCoder.com.

 

 

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish