The .NET Core Zoo

Unless you have been living under a rock, you may have noticed that Microsoft has been iterating at a furious pace on their .NET Core initiative for the past two years.

It is a clean reboot of the .NET Framework that is both open-source and cross-platform, targeting Windows, macOS and Linux.

For a company that has historically been an enemy of open-source software, it is difficult not to be amazed at the amount of openness that Microsoft is demonstrating with .NET Core. Not only have they released the entire stack as open source software but the development is also being done in the open on Github.

The issue with .NET Core is that it can easily be confused with older closed source products that Microsoft has released for the past 15 years. The problem is compounded by Microsoft’s willingness to re-use similar names to designate radically different underlying technologies.

In this post, I will provide you with an overview of .NET Core, ASP.NET Core and Visual Studio, and I will explain how the open-source flavors differ from their closed source relatives.

The Different Flavors of .NET Framework

Different flavors of the .NET framework have coexisted for some time. Typically each flavor combines a different runtime and a different set of standard libraries.

  • The .NET framework denotes the classical Windows-only .NET framework. This is the oldest flavor of .NET which shipped with Windows XP.

  • The .NET Core framework is the new open-source framework released in 2016. It works on Linux, macOS and Windows. Generally speaking, it can be considered as a subset of the older .NET Framework.

  • Xamarin Mono is a third party framework developed by open source Linux developers. It predates .NET Core by more than 10 years. It is also considered a subset of .NET Framework, because the Xamarin developers have never managed to quite catch up with Microsoft. However Mono also features special support for iOS, Android, Game Consoles, and Linux UI frameworks, which is entirely absent from Microsoft’s flavors.

  • .NET Standard is a recent initiative from Microsoft which formalizes the APIs shared by the different flavors of .NET. If your code targets .NET Standard, it should be able to run without recompiling on all flavors of .NET runtimes: .NET, .NET Core and Xamarin Mono.

The Different Versions of .NET Core

Microsoft’s download page for .NET Core shows many different options:

  • Microsoft offers both a Long Time Support (LTS) version and a regular version. The LTS version is older but Microsoft promises to support it for about 3 years. The downside is that it lags behind in terms of features.

  • A runtime and SDK versions. The SDK includes the runtime necessary for running .NET Core executables, but also all the development tools (i.e. the compiler and dotnet command line tool). Thus you only need to install one of them.

  • The Windows Server Hosting includes the runtime, but also a special module necessary to run ASP.NET Core sites within IIS. Since IIS is only available on Windows the Windows Server Hosting is not available on Linux nor macOS.

The Different Versions of Visual Studio

You can develop for .NET Core by using the text editor of your choice and the command line dotnet tool. However, I would highly recommend that you have a look at the different versions of Visual Studio that Microsoft provides.

  • Visual Studio 2017 for Windows. This is the traditional version of Visual Studio. The Community edition is free and fully featured when it comes to .NET and .NET Core development. The only downside is that you will probably have to use the paid-for Professional or Enterprise editions in a commercial setting.

  • Visual Studio Code is an open-source text editor based on Atom. It is a very capable text editor which also provides advanced IDE features, such as refactoring tools, compiler and debugger support for common languages including C#. It competes against Atom and Sublime Text.

  • Visual Studio 2017 for Mac. Although it shares the same name as the Windows version, it is a radically different piece of software based on Mono Develop. It is a bit rough and has definitely not achieved the level of maturity as the Windows counterpart. That being said, Visual Studio Code was in a similar state when it was introduced in 2015, and I am confident that Microsoft will iterate and make Visual Studio for Mac a lot better soon.

The Different Versions of ASP.NET

This the area where the marketing at Microsoft has gone wrong. The name ASP.NET Core refers to old technologies which gives this very modern and compelling framework a very bad press, in my opinion.

  • ASP, Active Server Pages is a very old technology released in the late 1990s. Think of it as a clone of PHP but using Visual Basic instead. It is also similar to what JSP for Java used to be. It was abandoned long ago and is not suitable for modern web application development.

  • ASP.NET superceded ASP in the early 2000s, and development shifted from Visual Basic to C#. It is a framework based on Web Forms, with a page template system powered by XML and uses the *.aspx file extension. The framework was invented before AJAX became mainstream, and a lot of effort seems to be devoted to make sure developers never write any JavaScript. It also integrates with the System.Web pipeline of IIS which, even though is a step up from CGI, makes use of global variables to represent the state of requests and responses. Even though it is still maintained, it is a technology that is clearly showing its age.

  • ASP.NET MVC is a modern framework that Microsoft introduced in 2009. It is inspired by the successful Ruby on Rails framework, and as the name indicates, features a clear separation between Models, Views and Controllers. It also introduced a better view template system named Razor and improved routing. Even though it is still integrated with the same System.Web IIS centric pipeline, it goes out of its way to hide that fact from developers, and wrap HTTP requests and responses into non-global variables, which can be mocked for the purpose of unit testing.

  • ASP.NET Web API is another framework Microsoft introduced in 2012. It is very similar to ASP.NET MVC, to the point that entire class hierarchies between the two frameworks share identical names and functions. But unlike ASP.NET MVC which focuses on generating dynamic HTML pages, ASP.NET Web API as the name indicates, targets the creation of Web APIs. It is a pretty good framework to write JSON RESTful APIs for instance.

  • Finally ASP.NET Core is a complete rewrite and a merge of both ASP.NET MVC and ASP.NET Web API. It was released in 2016 and is developed in the open on Github. It makes great use of dependency injection and provides support for writing middleware. ASP.NET Core web applications can be deployed to Linux servers or Docker containers.

The Different Versions of ASP.NET Core

As I indicated in the previous section, ASP.NET Core is a complete reboot of the Microsoft framework for writing web application software.

But the moniker ASP.NET Core denotes some radically different realities:

  • The version of ASP.NET Core which targets Kestrel. This is the main version that Microsoft is promoting. Kestrel is an open-source asynchronous HTTP server with very good performance characteristic. If you target .NET Core as your runtime, this is the only available option. Kestrel and .NET Core can be deployed to Linux (possibly using nginx or Apache as a reverse proxy). You can also target .NET Standard or .NET 4.7 for Windows. In this flavor of ASP.NET Core, the entire HTTP pipeline has been rewritten from scratch, and you can inject your own middleware, as in any modern web application framework.

  • The version of ASP.NET Core which integrates with the IIS pipeline. This flavor of ASP.NET Core integrates with the classic IIS pipeline introduced for ASP.NET and it relies on the System.Web classes and their global variables. If you adopt this flavor of ASP.NET Core you have to target .NET 4.7 and run the web application on IIS on a Windows Server. In addition some features, such as writing your own custom middleware, are not available. The advantage of this flavor of ASP.NET Core, is that it can be viewed as an incremental update from the old ASP.NET MVC and ASP.NET Web API frameworks. Unless you have some existing ASP.NET code, you should probably stay away from this configuration for new projects.

  • Finally you can use ASP.NET Core with Kestrel inside IIS. So this is the option where you are essentially using IIS as a reverse proxy for the Kestrel server. In this version you sort of get the best of both worlds: your Windows centric IT team can continue managing IIS sites as before, and you get all the features and performance improvements available to the Kestrel stack. This is achieved by installing a custom IIS module provided by Microsoft, which is called the ASP.NET Core Module. This is the recommended way to deploy ASP.NET Core on Windows servers. On Linux Microsoft recommends using nginx or Apache in similar reverse proxy configurations.

Conclusion

.NET Core and ASP.NET Core are very compelling open source technologies promoted by Microsoft. The frameworks, libraries, compilers and runtime are published on Github. You can use Visual Studio Code, another open-source piece of software to write C# code and deploy it to Linux, possibly via docker containers.

But make no mistake, Microsoft still has ways to make money:

  • Microsoft sells access to Azure, their own cloud computing platform which competes with the likes of AWS and Google Cloud. Naturally Azure integrates very well with ASP.NET Core.

  • Microsoft also sells Visual Studio 2017, which unlike Visual Studio Code is closed source software. Although it may be used for free under some circumstances, for most commercial settings you will have to pay a subscription to use it.

  • Microsoft is also strongly pushing SQL Server, their closed source relational database server. It has better integration than any other SQL databases with the .NET Core stack. Traditionally SQL Server used to run on Windows Servers only, but since the last release of SQL Server 2017 last October, the software can now be deployed to Linux servers as well.