A quick primer on .NET web frameworks

Update: Much to my embarrassment, I forgot to mention OpenRasta!

I’ve received quite a few questions in the past months and year about web frameworks for .NET (some confusion around the difference between WebForms, ASP.NET MVC, FubuMVC, ASP.NET in general, etc).  So I thought I’d make a quick blog post giving some real basic explanations of these frameworks, what the intended audience is for each, and what the strengths and weaknesses are of each.

Note: This is not an exhaustive list. It does not include all the frameworks that are out there. There are many good ones for .NET each with their own particular take on the matter. If you’re shopping for a framework, please do your research and only consider this post as one of many resources.

ASP.NET

ASP.NET is more of a foundational framework. I wouldn’t recommend developing a whole app directly against ASP.NET itself. All the frameworks mentioned below are built on TOP of ASP.NET and provide greater convenience and accelerators for making web development easier.  While it is possible to build an entire web application directly using ASP.NET HttpModules and HttpHandlers, I wouldn’t recommend it. It’s somewhat similar to doing Assembly language programming, but for the web.

Knowing and being familiar with the libraries, services, and facilities that ASP.NET provides is critical for doing development with any of the frameworks mentioned below.  So I highly recommend that you study ASP.NET, read documentation, examples, articles, and books on the subject.

ASP.NET Web Forms

ASP.NET Web Forms was developed at the same time as ASP.NET and was meant to be the primary framework for developers moving from VB6 and ASP (VBScript/JScript) development to the .NET framework.  Web Forms was intended to make web programming a familiar experience for VB6 developers who were used to Windows application event-driven development (i.e. Button1_Click events) and who were used to building user interfaces on designer surfaces by dragging and dropping controls.  Web Forms has some strengths in that it’s been around for awhile, it’s fairly comprehensive, and it’s approachable for many developers.  While you might at first thing that this is a strength, Web Forms’ greatest weakness is that it too abstracts the developer from the underlying realities of stateless HTTP-based web development.  Many critical aspects of web development are managed for the developer (sometimes in sub-optimal ways) leaving the web developer into problems when trying to anything outside of the normal Web Forms development path.

Web Forms has its place (for example, in small IT shops where the developer isn’t a full-time developer and just needs to quickly assemble a forms-over-data application).  For any serious web development effort, however, I would consider the friction and hand-tying effects of Web Forms too great to bear and so therefore I don’t recommend Web Forms for most development scenarios for .NET.

ASP.NET Web Forms is commercial closed-source, built by Microsoft and is still under active development. However, development has slowed recently in favor of the newer ASP.NET MVC framework.

Castle MonoRail

Castle MonoRail is an open source framework that was built, in large part, due to frustrations that web developers in .NET experienced with Web Forms – especially after having worked with several non-.NET frameworks and seeing how much easier many tasks were to perform.  MonoRail is still actively maintained and there are many production deployments using it as the core web framework. MonoRail can use various “view engines” including the “Web Forms” view engine, Brail, NVelocity, and others.  Its strengths are that it is a comprehensive framework, it fits well within the whole Castle family of projects, and allows for much more freedom than Web Forms.  It’s weaknesses include being fairly different from other forms of ASP.NET-based development (which some might consider a strength, so weigh this for your own team), and it has heavy dependence upon other Castle frameworks (which may not be an issue for all teams, but for some it is). 

In the interest of full disclosure, I admit that I don’t personally have a lot of experience with MonoRail so I cannot effectively discuss it’s strengths and weaknesses.  I know that many colleagues, whom I respect, use MonoRail with great effectiveness. So it is a serious contender and worthy of investigation if you are shopping for a web framework.

MonoRail is open source (contributions welcome).  It is under active development.

OpenRasta

OpenRasta is an open source framework. Their doc page explains it best when it says, “OpenRasta is a resource-oriented framework for .NET enabling easy ReST-ful development of web sites and services.”  OpenRasta however does have many MVC features and can serve as a full-fledge web application framework (i.e. it’s not *just* a REST framework).  OpenRasta’s strengths lie in it’s comprehensiveness, wide range of features, active development and support community plus good documentation. OpenRasta’s weaknesses are similar to other frameworks in that is not as approachable as Web Forms and is intended for experienced developers. 

Also in the interest of full disclosure, like MonoRail, I don’t have a lot of personal experience with OpenRasta and so I cannot effectively discuss it’s strengths and weaknesses.  Please investigate for yourself and engage the OpenRasta community for more information.

 

ASP.NET MVC

ASP.NET MVC is another framework built on TOP of ASP.NET (but not on top of Web Forms – MVC is parallel to Web Forms).  ASP.NET MVC was developed by Microsoft in response to complaints of .NET web-based developers who complained about design problems with Web Forms.  While you can mix Web Forms and MVC development in the same project, I wouldn’t recommend it unless there was a specific need to do it.  MVC does away with the cumbersome “Page Control Lifecycle” of Web Forms and provides a much more stream-lined approach to web development.  MVC is much closer to the inherent stateless request/response nature of HTTP and so therefore makes it much easier for experienced web developers (and even inexperienced ones) to develop complex web applications.  MVC is less focused on designer-based drag-and-drop programming and more on code-centric programming.  There sometimes is confusion about the difference between ASP.NET MVC and Web Forms because MVC can use *some* parts of Web Forms for presentation.  This is known as the “Web Forms View Engine”. There are also other view engines for ASP.NET MVC including Spark and Razor.  This allows you to use ASPX and ASCX files and some runat=”server” controls in your views, but without having to have code-behind files and Page Control Lifecycle event handling.   MVC’s strengths are similar to MonoRail in that it’s fairly comprehensive, and allows a lot more freedom of development and puts the developer back in touch with the fundamentals of web/HTTP programming.  It is well documented and has many guides and a great user community around it.

It shares the same weakness as MonoRail in that MVC is less approachable for less experienced developers.  For more experienced, advanced developers, certain design aspects of MVC can be cumbersome (such as the use of too much inheritance, problematic support for dependency injection and IoC tooling, and too much friction when writing unit tests). These weaknesses are not critical, however, and many good developers are using ASP.NET MVC quite effectively.  ASP.NET MVC is a good contender if you’re investigating frameworks and definitely worth some time to spike out some examples.

ASP.NET MVC is commercial open-source (contributions are not accepted, but you can view the source). It is currently in active development by Microsoft and is on its 3rd version.

FubuMVC

FubuMVC is another framework built on top of ASP.NET and sits at the same level (“competes” with if you will) Web Forms, MonoRail, and ASP.NET MVC.  FubuMVC was originally designed in response to the perceived issues (identified in the preceding section) with ASP.NET MVC.  The original designers felt that ASP.NET MVC was good, but didn’t go far enough in certain areas to be truly great. FubuMVC uses various view engines like ASP.NET MVC and MonoRail. Currently FubuMVC supports Spark and Web Forms view engines and a Razor engine is being considered.  FubuMVC’s strengths include being more IoC/DI and SOLID friendly than ASP.NET MVC.  It’s more compositional (versus inheritance-based) which allows for greater freedom for the developer. FubuMVC also has greater support for conventional development saving developers a lot of time in both development and testing by standardizing the aspects of their application that are similar. FubuMVC’s weaknesses include the same approachability issue that MonoRail and ASP.NET MVC, but I would say FubuMVC fairs worst in this regard. FubuMVC is designed for advanced, experienced developers.  FubuMVC also has a sore lack of documentation and guides at the moment.  FubuMVC is also not as comprehensive as ASP.NET MVC and MonoRail.  In some respects, FubuMVC has more functionality, but in (many) other respects it still has a ways to go.  Though FubuMVC has a small development team currently, but is gaining ground steadily and growing.

FubuMVC is open source (contributions welcome).  It is under active development.

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

About Chad Myers

Chad Myers is the Director of Development for Dovetail Software, in Austin, TX, where he leads a premiere software team building complex enterprise software products. Chad is a .NET software developer specializing in enterprise software designs and architectures. He has over 12 years of software development experience and a proven track record of Agile, test-driven project leadership using both Microsoft and open source tools. He is a community leader who speaks at the Austin .NET User's Group, the ADNUG Code Camp, and participates in various development communities and open source projects.
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.codeitalready.com T.J. Barbour

    Hi Chad,
    I’ve been developing with ASP.net MVC for a while but haven’t used too many of the advanced features. So, I was wondering if you could give an example of what you mean by “too much inheritance” in MVC. Where do people see too much inheritance being used and why is it a problem?
    Great post BTW! & Thanx!
    T.J. Barbour

  • http://www.lostechies.com/members/chadmyers/default.aspx chadmyers

    @T.J. Barbour:

    To do most interesting things in ASP.NET MVC, you have to derive from an (abstract, usually) base class (i.e. DefaultControllerFactory) and override some template methods.

    What we found at Dovetail, is that in many circumstances, the template method didn’t over enough visibility into what the base class was doing. We also found that if we wanted to override a little something here or there, we ended up having to duplicate or copy much of the base class code to accomplish it. This is the basic problem with inheritance and the template method pattern — it’s usually never enough and is a poor attempt at adding elements of composition to an inheritance-based design.

    If you click the link in the post on the word “compositional”, you’ll see my post on the subject. Also, you can google for “composition vs inheritance” and find a wealth of information.

  • Jeffrey Cameron

    Hey Chad,

    Why no mention of OpenRasta? It too is a web development framework in the .NET ecosphere.

  • http://www.lostechies.com/members/chadmyers/default.aspx chadmyers

    @Jeffrey:

    What do you mean? OpenRasta’s right there, right under MonoRail (I was doing things in chronological order).

    haha, just joshing with you. I realized my mistake a moment before you posted that comment and updated the post. Good catch.

    I wasn’t trying to be exhaustive in my list, but you’re right that OpenRasta is considerable in size, scope, and usage so it should be included even in a quick punch list like this. And that’s why I added it.

  • Jeffrey Cameron

    Ok, you got me good there. I had to do a double-take! :)

  • http://www.codeitalready.com T.J. Barbour

    @Chad Thanks for the clarification, I appreciate the explanation.

  • http://twitter.com/jakescott Jake Scott

    Sinatra inspired framework for .net http://github.com/skoon/Boat
    Also RackSharp for .net http://github.com/skoon/Boat/tree/master/lib/RackSharp/

    Plugins need to build into these frameworks so that we can plugin components like Rails

    Thoughts?

  • http://www.lostechies.com/members/chadmyers/default.aspx chadmyers

    @Jake:

    Thanks for posting those. Sinatra and Rack are both pretty cool. We have been considering adding a Sinatra like features to FubuMVC for awhile now. I really like the concepts it proposes.

  • Craig

    Interesting article, but I bristle a little at this comment:

    “For any serious web development effort, however, I would consider the friction and hand-tying effects of Web Forms too great to bear and so therefore I don’t recommend Web Forms for most development scenarios for .NET.”

    I wonder if the thousands of commercial sites that have been developed using WebForms know that “the friction and hand-tying” are “too great to bear?”

    I’m just getting a little tired of the “oh, look, new and shiny” attitude towards .NET development. Oh, something new… that stuff we’ve been doing for the last decade really sucks, huh? Perhaps a little less, “Look how smart I am ’cause I’m edgy and have abandoned the ‘old ways’ and a little more objectivity would be in order.

  • http://www.lostechies.com/members/chadmyers/default.aspx chadmyers

    @Craig:

    The Egyptians built the pyramids with simple tools. It was the best way they had to do the work then. But is that the best way to built huge buildings now?

    Technology evolves. Just because someone built amazing things with poor tools doesn’t mean that it’s the best way to do it.

  • http://peter@pseale.com Peter

    —————————– THANKS FOR YOUR PARTICIPATION! BUT PLEASE, NO MORE WEBFORMS DISCUSSION BELOW THIS LINE ———————–

  • http://hadihariri.com Hadi Hariri

    @Craig,

    The irony about the “oh, look, new and shiny” is that MVC is far from new or shiny. It’s a pattern that has been around for decades. The “new” thing here is that Microsoft decided to make a framework one of their own.

    Of course WebForms is used commercially throughout the world and of course many web sites have been built on it, I don’t think anyone is denying that. However, if all you’ve done is WebForms and discard everything else as a new fad, surely you won’t see the benefits that these other new and shiny things might just have.

  • http://www.vanderleipereiras.com/blog Vanderlei Pereira

    Hi Chad,
    Nice post! I´m developing web applications in Brazil and I found some difficult to write unit tests using asp.net mvc, but I like very much to use this kind of framework because you can improve your knowledge diving deep in how it works.

  • Jay Glynn

    And there have been some awful things built with great tools. It’s not as much about the tooling as it is about the person using the tools. We can sometimes put to much emphasis on tools and frameworks and not enough on good engineering principles.

  • Matthew

    ASP.NET MVC:

    > “[...] makes it much easier for [...] (and even inexperienced ones) to develop complex web applications.”

    Sorry, strongly disagree!

  • TimMahy

    I think it’s wrong to say that Webforms are not suitable in most cases, when application development (not website development), webforms gives a very nice abstraction which enables you to build solid applications. Combined with an MVP approach, you get best of both worlds. Component based UI’s aren’t bad by design, they are an abstraction, and in most cases abstractions are good. And there is nothing that you cannot do in Webforms that you can’t do in pure ASP.NET or MVC….

  • http://www.vanderleipereiras.com/blog Vanderlei Pereira

    @Jay Glynn

    We find here a lot of mistakes made even by high level professionals, hired as senior because their certificates and tittles but these facts don´t give any guarantee that they are able to get the job done with quality.
    The basic idea of this article is to describe some characteristics of the most used web frameworks using .Net and it´s ok for me.

  • Thedric Walker

    @TimMahy Actually there is one thing that you can’t do with WebForms that you can do with MVC. You can have multiple forms on one page.

  • http://blog.elliottohara.com Elliott O’Hara

    “and in most cases abstractions are good”

    except when the abstraction is more complicated than the thing that was attempted to “abstract away”

    Http Gets and Post are pretty simple…But memorizing what happens during the lifecycle of a webform is comic.

  • http://www.casualmiracles.com Lance Walton

    The Egyptian approach to building things was to throw a lot of people at it. Some of them got crushed in the process.

    A bit like software development these days.

  • http://www.casualmiracles.com Lance Walton

    @Elliot O’Hara

    By definition, abstractions are never more complicated than the thing being abstracted. If it appears this has happened, then somebody has made a mess, not an abstraction.

  • Steve

    “MVC is less approachable for less experienced developers”

    In my opinion – Webforms are less approachable and more complex than MVC. MVC is a common structure for most web frameworks- and is actually straightforward.

    This is why many Webform projects turn out so unwieldy. The page lifecycle often times gets in the way for a ‘less experienced developer’ – most I’ve seen struggle much with this lifecycle.

    I’d go as far as to say – if MVC would have come before Webforms, the shift from asp developers would have been easier. When I trained some asp developers on Webforms the abstraction/page lifecycle and controls caused much confusion

    So, in that area I’d disagree with that assessment.

    Most Webform devs struggle with the switch to mvc because there aren’t really controls like a ‘GridView’ – once you show them how to use some of the javascript controls they are ok

  • Steve

    “MVC is less approachable for less experienced developers”

    In my opinion – Webforms are less approachable and more complex than MVC. MVC is a common structure for most web frameworks- and is actually straightforward.

    This is why many Webform projects turn out so unwieldy. The page lifecycle often times gets in the way for a ‘less experienced developer’ – most I’ve seen struggle much with this lifecycle.

    I’d go as far as to say – if MVC would have come before Webforms, the shift from asp developers would have been easier. When I trained some asp developers on Webforms the abstraction/page lifecycle and controls caused much confusion

    So, in that area I’d disagree with that assessment.

    Most Webform devs struggle with the switch to mvc because there aren’t really controls like a ‘GridView’ – once you show them how to use some of the javascript controls they are ok

  • Steve

    By the way, where is the ‘download binaries’ button on the FubuMVC main page?

    One last thing: I was able to setup IOC in mvc with around 4-5 lines of code using Castle Windsor + MvcContrib. It wasn’t that difficult at all – (this is a project with a repository/service/domain structure). Certainly the struggle wasn’t with mvc, more with learning IoC for most people?

  • http://www.lostechies.com/members/chadmyers/default.aspx chadmyers

    @Steve:

    Let me deal with the FubuMVC binaries question first: On the http://www.fubumvc.com homepage, click “artifacts” in the TeamCity build widget at the bottom. I know, not very intuitive. I’ll look into making that easier.

  • http://www.lostechies.com/members/chadmyers/default.aspx chadmyers

    @Steve:

    RE: MVC vs. WebForms approachability: I see your point and it is valid for professional programmers. So I agree with that completely. I was trying to make a slightly different point: With Web Forms a developer who is not that good at coding (maybe an IT guy who’s been asked for build a simple forms-over-data app) can drag-and-drop an application together with relative ease and get going fast with very little code. So, the point I was trying to make is that Web Forms is approachable for a larger audience.

    RE: IoC – MVC has real basic “at arms length” support for IoC and doesn’t really take advantage of most of the features of IoC containers like Windsor or StructureMap.

  • http://blog.agafonov.net.ua Slava

    What about usual WebForms? Now it is very optimized especially .NET 4.0 ASP.NET