.NET 5 vs. .NET Framework for server apps
There are two supported .NET implementations for building server-side apps: .NET Framework and .NET 5 (including .NET Core). Both share many of the same components and you can share code across the two. However, there are fundamental differences between the two and your choice depends on what you want to accomplish. This article provides guidance on when to use each.
Use .NET 5 for your server application when:
- You have cross-platform needs.
- You're targeting microservices.
- You're using Docker containers.
- You need high-performance and scalable systems.
- You need side-by-side .NET versions per application.
Use .NET Framework for your server application when:
- Your app currently uses .NET Framework (recommendation is to extend instead of migrating).
- Your app uses third-party .NET libraries or NuGet packages not available for .NET 5.
- Your app uses .NET technologies that aren't available for .NET 5.
- Your app uses a platform that doesn't support .NET 5.
When to choose .NET 5
The following sections give a more detailed explanation of the previously stated reasons for picking .NET 5.
If your application (web/service) needs to run on multiple platforms (Windows, Linux, and macOS), use .NET 5.
.NET 5 supports the previously mentioned operating systems as your development workstation. Visual Studio provides an Integrated Development Environment (IDE) for Windows and macOS. You can also use Visual Studio Code, which runs on macOS, Linux, and Windows. Visual Studio Code supports .NET 5, including IntelliSense and debugging. Most third-party editors, such as Sublime, Emacs, and VI, work with .NET 5. These third-party editors get editor IntelliSense using Omnisharp. You can also avoid any code editor and directly use the .NET Core CLI, available for all supported platforms.
A microservices architecture allows a mix of technologies across a service boundary. This technology mix enables a gradual embrace of .NET 5 for new microservices that work with other microservices or services. For example, you can mix microservices or services developed with .NET Framework, Java, Ruby, or other monolithic technologies.
There are many infrastructure platforms available. Azure Service Fabric is designed for large and complex microservice systems. Azure App Service is a good choice for stateless microservices. Microservices alternatives based on Docker fit any kind of microservices approach, as explained in the Containers section. All these platforms support .NET 5 and make them ideal for hosting your microservices.
For more information about microservices architecture, see .NET Microservices. Architecture for Containerized .NET Applications.
Containers are commonly used in conjunction with a microservices architecture. Containers can also be used to containerize web apps or services that follow any architectural pattern. .NET Framework can be used on Windows containers, but the modularity and lightweight nature of .NET 5 makes it a better choice for containers. When creating and deploying a container, the size of its image is much smaller with .NET 5 than with .NET Framework. Because it's cross-platform, you can deploy server apps to Linux Docker containers, for example.
Docker containers can be hosted in your own Linux or Windows infrastructure, or in a cloud service such as Azure Kubernetes Service. Azure Kubernetes Service can manage, orchestrate, and scale container-based applications in the cloud.
High-performance and scalable systems
When your system needs the best possible performance and scalability, .NET 5 and ASP.NET Core are your best options. High-performance server runtime for Windows Server and Linux makes .NET a top performing web framework on TechEmpower benchmarks.
Performance and scalability are especially relevant for microservices architectures, where hundreds of microservices may be running. With ASP.NET Core, systems run with a much lower number of servers/Virtual Machines (VM). The reduced servers/VMs save costs in infrastructure and hosting.
Side by side .NET versions per application level
To install applications with dependencies on different versions of .NET, we recommend .NET 5. .NET 5 supports side-by-side installation of different versions of the .NET 5 runtime on the same machine. This side-by-side installation allows multiple services on the same server, each of them on its own version of .NET 5 (or .NET Core 2.1 or 3.1). It also lowers risks and saves money in application upgrades and IT operations.
Side-by-side installation isn't possible with .NET Framework. It's a Windows component, and only one version can exist on a machine at a time. Each version of .NET Framework replaces the previous version. If you install a new app that targets a later version of .NET Framework, you might break existing apps that run on the machine, because the previous version was replaced.
When to choose .NET Framework
.NET 5 offers significant benefits for new applications and application patterns. However, .NET Framework continues to be the natural choice for many existing scenarios, and as such, .NET Framework isn't replaced by .NET 5 for all server applications.
Current .NET Framework applications
In most cases, you don't need to migrate your existing applications to .NET 5. Instead, a recommended approach is to use .NET 5 as you extend an existing application, such as writing a new web service in ASP.NET Core.
Third-party libraries or NuGet packages not available for .NET 5
.NET Standard enables sharing code across all .NET implementations, including .NET 5. With .NET Standard 2.0, a compatibility mode allows .NET Standard and .NET 5 projects to reference .NET Framework libraries. For more information, see Support for .NET Framework libraries.
You need to use .NET Framework only in cases where the libraries or NuGet packages use technologies that aren't available in .NET Standard or .NET 5.
.NET technologies not available for .NET 5
Some .NET Framework technologies aren't available in .NET 5. The following list shows the most common technologies not found in .NET 5:
ASP.NET Web Forms applications: ASP.NET Web Forms are only available in .NET Framework. ASP.NET Core cannot be used for ASP.NET Web Forms.
ASP.NET Web Pages applications: ASP.NET Web Pages aren't included in ASP.NET Core.
WCF services implementation. Even when there's a WCF client library to consume WCF services from .NET 5, WCF server implementation is currently only available in .NET Framework.
Workflow-related services: Windows Workflow Foundation (WF), Workflow Services (WCF + WF in a single service), and WCF Data Services (formerly known as "ADO.NET Data Services") are only available in .NET Framework.
Language support: Visual Basic and F# are currently supported in .NET 5, but not for all project types. For a list of supported project templates, see Template options for dotnet new.
For more information, see .NET Framework technologies unavailable in .NET 5.
Platform doesn't support .NET 5
Some Microsoft or third-party platforms don't support .NET 5. Some Azure services provide an SDK not yet available for consumption on .NET 5. In such cases, you can use the equivalent REST API instead of the client SDK.