为什么 运行 ASP.NET Core on .NET Core over .NET on Windows Server

Why run ASP.NET Core on .NET Core over .NET on Windows Server

自从我听说 ASP.NET Core.NET Core 以来,我一直想知道为什么您要在 .NET Core 上开发一个 ASP.NET Core web application 运行 .NET 如果你是 运行 一个 Windows 服务器,比如 Windows Server 2012?我可以理解,如果你正在为 Ubuntu 之类的其他东西开发跨平台,但如果你是 运行 一个 Windows 服务器,你为什么要开发 .NET Core 路线?

有什么好处(如果有的话)?我觉得我在这里遗漏了什么?这是进行 ASP.NET Web 开发和部署的理想方式吗?您什么时候想使用完整的 .NET 框架进行 ASP.NET 网络开发而不是 .NET Core 框架?

不是每个人都在为跨平台开发?我一生都在为 Windows 服务器开发,从来不需要做任何跨平台的事情。我不认为我会使用 .NET 开发任何跨平台的东西——我可能会使用 .NET 以外的东西(如果我走这条路)。

希望有人能帮我解惑?

.NET Core

ASP.NET 可以 运行 在 .NET Core 上 在完整的 .NET Framework 上。 .NET Framework 运行仅在 Windows 上使用,并使用 .NET Framework 的 完整 足迹。

如果您不需要以下内容,您仍然可以使用完整的 .NET 框架:

.NET Core 是主机/OS 不可知论者

You can run your apps on different OS's and hosts:

  • Linux, Windows, MAC
  • IIS, Console app, ..

可用于设备、云和embedded/IoT场景。

模块化

.NET Core is a modular runtime and library implementation that includes a subset of the .NET Framework.

意味着,您可以通过 nuget 只安装需要的包。

便携性:

You can package and deploy the CoreCLR with your application, eliminating your application’s dependency on an installed version of .NET (e.g. .NET Framework on Windows). You can host multiple applications side-by-side using different versions of the CoreCLR, and upgrade them individually, rather than being forced to upgrade all of them simultaneously.

减少足迹

By factoring the CoreFX libraries and allowing individual applications to pull in only those parts of CoreFX they require (a so-called “pay-for-play” model), server-based applications built with ASP.NET can minimize their dependencies.

应用模型

.NET Core does not support all the .NET Framework app-models, in part because many of them are built on Windows technologies, such as WPF (built on top of DirectX). The console and ASP.NET Core app-models are supported by both .NET Core and .NET Framework.

API

.NET Core contains many of the same, but fewer, APIs as the .NET Framework, and with a different factoring (assembly names are different; type shape differs in key cases). These differences currently typically require changes to port source to .NET Core. .NET Core implements the .NET Standard Library API, which will grow to include more of the .NET Framework BCL API over time.

子系统

.NET Core implements a subset of the subsystems in the .NET Framework, with the goal of a simpler implementation and programming model. For example, Code Access Security (CAS) is not supported, while reflection is supported.

Patches/Updates:

This, in turn, reduces the frequency with which patches and updates to the framework will impact these applications, since only changes made to the individual pieces of CoreFX leveraged by the application will impact the application.

部署:

A smaller deployment size for the application is a side benefit, and one that makes more of a difference if many applications are deployed side-by-side on a given server. Can be included in your app or installed side-by-side user- or machine-wide.

开源:

The .NET Core platform is open source, using MIT and Apache 2 licenses. Documentation is licensed under CC-BY. .NET Core is a .NET Foundation project. .NET Core is open source, while a read-only subset of the .NET Framework is open source.

运行 ASP.NET 如果你在 运行 上使用 Windows,那么完整框架上的核心工作得很好,事实上,这就是我选择用于移植旧框架的方法Web 表单应用程序。如果您不需要跨平台支持,我认为 ASP.NET Core on the full framework 是一个不错的选择。

.NET Core Framework 的功能远不如 Full Framework,而且将遗留应用程序移植到它可能要困难得多。例如目前不支持图像处理。

但是,除了它是跨平台的事实之外,以 .NET Core Framework 为目标的一大好处是它比 Full Framework 占用空间小得多,并且可以通过应用程序的文件复制进行部署。这意味着目标服务器不需要在部署前安装 .Net 框架来 运行 您的代码。这在您无法控制服务器级别安装的某些云托管情况下很有用,并且在部署到 IoT 设备等受限环境时很有用。

就是说,我怀疑会有很多 ASP.NET 编写的核心应用程序来支持完整框架。在某些方面,这是一个美丽的配对。一方面,您可以获得超轻量级和快速的 ASP.NET 带有标签帮助程序和所有优点的核心网络平台,另一方面,您仍然可以访问 Windows 一个功能齐全的框架,那么多.Net 开发人员了解并喜爱。