.NET Core vs ASP.NET Core - asp.net-core

What exactly is the difference between .NET Core and ASP.NET Core?
Are they mutually exclusive? I heard ASP.NET Core is built on .NET Core, but it can also be built on the full .NET framework.
So what exactly is ASP.NET Core?

Update 2020: Do note that ASP.NET Core 3 and higher now depend on .NET Core and can no longer be used on .NET Framework. The below description is for ASP.NET Core 1.x-2.x; the layer separation still holds true for ASP.NET Core 3.0 but the ASP.NET Core layer can no longer be used on top of .NET Framework in 3.0+.
.NET Core is a runtime. It can execute applications that are built for it.
ASP.NET Core is a collection of libraries that form a Framework for building web applications.
ASP.NET Core libraries can be used on both .NET Core and the "Full .NET Framework" (which has shipped with windows for many years).
The confusing part is that an application using the libraries and tools of ASP.NET Core is usually referred to as "ASP.NET Core Application", which in theory doesn't say if it is built for .NET Core or .NET Framework. So an "ASP.NET Core Application" is also a ".NET Core Application" or a ".NET Framework Application".
This image shows the relation of the involved technologies (taken from this blog post)
Here you can see that ASP.NET Core is built "on top of" both .NET Framework and .NET Core, while "ASP.NET" (now often referred to as "classic ASP.NET") is .NET Framework only.

ASP.NET Core using .NET Core - all dependencies are self-contained, can use most NuGet packages, can't use Windows-specific packages, can execute on Windows, Linux, and Mac.
ASP.NET Core using .NET Framework - most dependencies are self-contained, only executes on Windows, will have access to Windows-specific NuGet packages, needs the .NET framework version which is targeted installed on the machine.

ASP.NET Core is one of the workloads supported by .NET Core.
From .NET Core guide:
By itself, .NET Core includes a single application model -- console apps -- which is useful for tools, local services and text-based games. Additional application models have been built on top of .NET Core to extend its functionality, such as:
ASP.NET Core
Windows 10 Universal Windows Platform (UWP)
Xamarin.Forms

The .NET Framework is on its last release. There will not be another one after 4.8. Microsoft will continue with .NET Core. From this time you should prefer .NET Core on your projects.
Official update (source):
.NET 5 is the next major release of .NET Core following 3.1. We named this new release .NET 5 instead of .NET Core 4 for two reasons:
We skipped version numbers 4.x to avoid confusion with .NET Framework 4.x.
We dropped "Core" from the name to emphasize that this is the main implementation of .NET going forward. .NET 5 supports more types of apps and more platforms than .NET Core or .NET Framework.
ASP.NET Core 5.0 is based on .NET 5 but retains the name "Core" to avoid confusing it with ASP.NET MVC 5. Likewise, Entity Framework Core 5.0 retains the name "Core" to avoid confusing it with Entity Framework 5 and 6.

.NET Core is the next evolution of the .NET Framework, that allows Microsoft technology to be hosted on other OS platforms, rather than Windows.
ASP.NET is the web framework provided by Microsoft for building:
server-side rendered web pages/websites
server-side components for SPAs
MVC-fashion apps
web services/web APIs/microservices
ASP.NET runs only on Windows platforms.
Since .NET Core was created to provide the capability of running Microsoft tech on top of Linux/macOS, it implies that ASP.NET Core is the evolution of ASP.NET in the direction of multi-platform support.
In conclusion:
ASP.NET Core runs on both .NET Core and .NET 5.0, on top of multiple OS platforms: Windows, Linux & macOS.
ASP.NET 4.x (ASP.NET/ASP.NET MVC) runs on the .NET Framework only, on top of Windows OS.

Related

Helper library for ASP.NET Core 5 - NuGet packages not available?

I'm writing a helper library for ASP.NET Core 5 (with .NET 5) and I need some APIs from the package Microsoft.AspNetCore.Server.Kestrel.Core. However, the package is only available in version 2.2 - not version 5.
Is ASP.NET Core no longer distributed via NuGet? And if so, how does one get the APIs with ASP.NET Core 5.
Side note: I found that I could use Microsoft.NET.Sdk.Web as SDK for the project but I'm unsure whether this is a valid/good/correct approach when writing a library.
Is ASP.NET Core no longer distributed via NuGet? And if so, how does one get the APIs with ASP.NET Core 5.
That's correct. The core of ASP.NET Core (no pun intended...) ships with .NET Core >= 3.0 as a shared framework. You can add a single FrameworkReference to your nuget package to pull this in. See https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-5.0&tabs=visual-studio#migrate-libraries-via-multi-targeting for more information.
Some background can be found here https://github.com/dotnet/aspnetcore/issues/3756

What will happen to the Microsoft.AspNetCore.* namespace in ASP.NET 5.0?

.NET 5.0 will replace .NET Core 3.x when it is released in November—and, thus, ASP.NET 5.0 will replace ASP.NET Core 3.x.
Edit: This question is based on a fundamentally incorrect assumption. While the next version of .NET Core will, in fact, be .NET 5.0, the next version of ASP.NET Core will be ASP.NET Core 5.0. See the answers from #Camilo-Terevinto and #omajid for details.
Despite this, as of Preview 8 (8.20414.8), packages, assemblies, and namespaces still contain AspNetCore in their names. For example, see the following NuGet packages:
Microsoft.AspNetCore.Http.Features
Microsoft.AspNetCore.Authorization
Microsoft.AspNetCore.DataProtection
Microsoft.AspNetCore.Razor.Language
If you go to the documentation for e.g. the Microsoft.AspNetCore.Http.Features namespace on learn.microsoft.com, however, you'll be redirected back to the ASP.NET Core 3.1 documentation with the warning:
The requested page is not available for ASP.NET Core 5.0 Preview. You have been redirected to the newest product version this page is available for.
Question: Do we have any evidence of what these packages, assemblies, and namespaces will be named in the .NET 5.0 release? Will they remain Microsoft.AspNetCore for backward compatibility, as the current namespaces suggest? Will they become Microsoft.AspNet for consistency with the product name, as the documentation suggests? Or does this remain TBD?
Background: Like other developers, I am working on the .NET 5.0 version of an open source library, and we aim to follow the same naming conventions as the underlying framework for the sake of familiarity, discovery, and consistency.
and, thus, ASP.NET 5.0 will replace ASP.NET Core 3.x.
That is not accurate, ASP.NET Core 5.0 will replace ASP.NET Core 3.x. The moniker that will change is .NET Core to .NET. Migration guide ASP.NET Core 3.x to ASP.NET Core 5.0.
Basically:
.NET Framework 4.8 -> .NET 5
.NET Core 3.1 -> .NET 5
ASP.NET Core 3.1 -> ASP.NET Core 5
thus, ASP.NET 5.0 will replace ASP.NET Core 3.x.
No, it won't. It's an unfortunate point of confusion, but it's not true.
Let me quote David Fowler, who is one of the ASP.NET Core architects:
There's no plan to change asp.net core to asp.net.
.NET Core becomes .NET 5, but ASP.NET Core stays as ASP.NET Core.

It's correct reference .NET Core from .NET Framework project?

I have an ASP NET MVC project with net471 target framework but I found nuget reference to Microsoft.AspNetCore.* or Microsoft.EntityFrameworkCore.*
It's correct? What problems can it entail?
It depends. First, I'm not sure if you're using terminology correct. Do you have an ASP.NET MVC 5 project or an ASP.NET Core project? If the former, then yes, it's very much incorrect. If the latter, then no it's fine, depending on the ASP.NET Core version.
.NET Framework 4.7.1 implements .NET Standard 2.0, which .NET Core 2.2 is also compatible with. Therefore, you can include ASP.NET Core 2.2 packages in a .NET Framework 4.7.1 project. Despite the name, an ASP.NET Core web app doesn't have to actually run on .NET Core. However, ASP.NET Core 3.0 or EF Core 3.0 would not work because those depend on .NET Standard 2.1, which no version of .NET Framework implements (and probably never will).

Using Entity Framework 6 in ASP.NET Core

Let's say I have:
ASP.NET Core stand alone Web API project for .NET Core framework
Class Library with EF6 data model for full .NET framework
The ASP.NET Core project refers to the class library
This architecture proposed here:
https://learn.microsoft.com/en-us/aspnet/core/data/entity-framework-6
The question is: will my standalone application be able to execute on the specified target platform (Win, Linux, Mac runtime) after Release (or Publish), if it's dependency targets to full .NET Framework?
Thanks very much
It will be not possible. The same link you provided confirm that:
To use Entity Framework 6, your project has to compile against .NET Framework, as Entity Framework 6 does not support .NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core.
You can use ASP.NET Core upon .NET Framework (Not .NET CORE) and EF6 (But not cross-platform). But not ASP.NET Core upon .NET Core and use EF6. You will need to use EF Core for that project.
Disclaimer: I'm the owner of the project Entity Framework Classic
That's not possible directly Entity Framework as #Adailson answered
However, it's possible via EF Classic: http://entityframework-classic.net/
That's an EF6 fork that also supports .NET Core. We plan to integrate a ton of features & bug fix.
A community (FREE) and enterprise version (PAID) is available.
What's EF Classic
Entity Framework Classic is a supported version from the latest EF6 code base. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.

How .NET Core, Mono and ASP.NET are related on a non Windows platform?

This breaks down to some trivial sub-questions
Is .NET Core a Mono alternative?
Will ASP.NET 5.0 run with .NET Core or with Mono in an OSX/Ubuntu environment?
I am confused, becasue I started at the .NET Core site, followed links toward ASP.NET 5 RC that all the way mentions Mono.
Is .NET Core a Mono alternative?
Yes, in the sense that .NET Core is also a cross platform framework. The difference is that Mono is an implementation of the full .NET framework, while .NET Core is only a subset of the full .NET framework (and their code diverges), and framework packages are obtained via NuGet.
Will ASP.NET 5.0 run with .NET Core or with Mono in an OSX/Ubuntu environment?
I can't speak for Mono, but ASP.NET 5 (which is soon to be renamed ASP.NET Core) will run on .NET Core on OS X (for development) and Ubuntu (for production or development) as well as Windows. ASP.NET 5 will also run on the full .NET Framework 4.6 on Windows.