Microsoft has released two further ASP.NET frameworks as open source, joining ASP.NET MVC which was already open source. These are published on CodePlex, Microsoft’s open source repository site, using the newly added Git support. You can find the code here.
The two additional frameworks are ASP.NET Web API and ASP.NET Web Pages. Just to recap, ASP.NET supports several frameworks:
ASP.NET Web Forms: the original framework shipped with .NET 1.0 and greatly enhanced since then. Excellent for quickly assembling a dynamic web site but somewhat heavyweight with its ViewState field and complex page lifecycle. Designed in pre-Ajax days.
ASP.NET MVC: A more elegant framework with separation of content from code, amenable to test-driven development, based on controllers and routing.
ASP.NET Web Pages formerly known as Razor: An alternative view engine designed to work with ASP.NET MVC. Uses .cshtml or .vbhtml extension in place of .aspx. A declarative language with codewords like @foreach and @if – though Microsoft’s Scott Guthrie says it is not a language but rather a template markup syntax.
ASP.NET Web API: formerly known as WCF Web API is a framework for building REST services. A key framework if you have a cloud + mobile target in mind. Now gets installed with ASP.NET MVC.
So why is ASP.NET Web Forms not open source? According to Microsoft’s Scott Hanselman:
The components that are being open sourced at this time are all components that are shipped independently of the core .NET framework, which means no OS components take dependencies on them. Web Forms is a part of System.Web.dll which parts of the Windows Server platform take a dependency on. Because of this dependency this code can’t easily be replaced with newer versions expect when updates to the .NET framework or the OS ships.
though it is not clear why this prevents the code being published.
Hanselman adds that Microsoft is not only publishing the code, but also taking contributions:
Today we continue to push forward and now ASP.NET MVC, Web API, Web Pages will take contributions from the community.
Why is Microsoft doing this? Within Microsoft, there have always seemed to be open source advocates like Hanselman, and others who pull back. One answer is that the open source folk are winning more arguments now.
Another take is that this is the outcome of industry-wide changes. Microsoft’s platform is less dominant than it was; it still reigns on the desktop, but Macs, tablets and smartphones are eroding its position on the client, and on the web Netcraft’s figures show steady decline since June 2010:
Most of the competition is open source and it is possible that this is a factor behind the latest moves. Microsoft is not open sourcing its IIS web server yet, though Hanselman does make the point that ASP.NET MVC runs well on Mono, the open source implementation of the .NET Framework, which is often used with Apache.