Shift --> MVC

MVC isn’t new, and neither is the concept of applying it toASP.NET. But it does have some advantages, as Jonathan Goodyear explains.

Jonathan Goodyear

October 30, 2009

3 Min Read
ITPro Today logo

Back Draft

 

Shift --> MVC

 

By Jonathan Goodyear

 

Undoubtedly, the biggest news in the world of ASP.NET thispast fall was Scott Guthrie s announcement of the Microsoft ASP.NET MVCFramework (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 releasedby the end of November. After a relatively slow summer for new ASP.NETtechnology out of the Redmondgiant, this was all very exciting.

 

For those of you like me who may be acronym-impaired, MVCstands for Model-View-Controller, which is a well established softwaredevelopment pattern that has been around for years. I won t bore you with atutorial 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 sMonoRail platform is just one example of a third-party MVC framework forASP.NET (http://www.castleproject.org/monorail/).Microsoft is bringing the concept of MVC to the ASP.NET masses, though, with anofficially blessed implementation. This is important, because many companieswill not allow developers to use tools or platforms that are not officially supportedby a corporate entity of some sort. Some of the other advantages of Microsoft sMVC Framework include:

  • Microsoft is creating Visual Studio projecttemplates to support everything that you can do with its MVC Framework.

  • It supports using ASPX, User Controls, andMaster Pages for the View part of the pattern. Other MVC frameworks rely onopen-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. Forinstance:

  • ViewState. This is a crutch that many developers(myself included) rely upon daily to keep track of their Web control state. Themore 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 havingthis is not appealing to me. I m sure Microsoft will have a solution to easethe pain, though.

  • PostBack. Microsoft wanted to make it reallyeasy for Windows developers to move to Web development, and PostBack enablesthem to create familiar event-driven user experiences. Unfortunately, ASP.NETaccomplished this through a hack known as the page lifecycle, which introducesits own set of frustrations.

  • Control variety. Because ViewState and PostBackare not supported by Microsoft s MVC Framework, many of the rich ASP.NETcontrols you know and love will have limited functionality. Microsoft hasannounced they will release a set of MVC-compliant controls to complement theexisting WebForms controls, but I m sure they will not be releasing a full setall at once. Compound that with the fact that third-party component vendorswill need to release updated versions of their own controls. Right now, they restill scrambling to release WPF and Silverlight controls, so they may not havethe 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 pasttense just yet. Microsoft is not discontinuing that Web development paradigm,and, in fact, will still be innovating and enhancing it. You can even useWebForms and MVC in the same Web project, so you can plug in new parts of your Webapplication using the MVC pattern if it suits your fancy. I m going to beworking with some pre-release versions of Microsoft s MVC Framework over thenext few months, and will definitely have more to report on. I definitely likewhat I ve seen so far. Until then, Scott Guthrie has written a pretty goodintroductory tutorial (http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx).

 

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

 

 

 

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like