ASP.NET Core MVC 2.0 Cookbook
上QQ阅读APP看书,第一时间看更新

Getting ready

For cost consideration, we may be interested in hosting our websites on a Linux infrastructure. With cloud possibilities, we can consider hosting a Linux VM with ASP.NET Core capabilities.

For this recipe, we will use Ubuntu 17.10, but you can use a different Linux distribution such as Debian, CentOS, Fedora or any Linux distribution that supports a Docker Engine.

Before .NET Core, there was the Mono Framework (http://www.mono-project.com/) to run a .NET application on Linux. Mono is an open source and a cross-platform port of the .NET Framework, which contains an Apache module to host ASP.NET applications.

For now, .NET applications always need Mono to run on Linux or OS X, because not all the BCL (The .NET Framework base class library) is fully ported on Linux.

To host our ASP.NET Core 2.0 application on Linux, we will use Kestrel (you can read more about this at https://github.com/aspnet/KestrelHttpServer) as a WebServer, which is a lightweight cross-platform web server able to execute ASP.NET Core code. Kestrel uses Libuv internally as a multi-platform asynchronous IO and TCP library, also used by Node.js.

For the moment, there's no other web server we could use to host ASP.NET Core applications on Linux or macOS, and Kestrel is not production-ready. We can also use IIS or WebListener as a web server to host ASP.NET Core applications, but exclusively on Windows.