Difference between using the ASP.NET Core Web Application (.NET Core) with net461 set as the only framework and using the (.NET Framework) template

33,416

Solution 1

What is the difference between creating a ASP.NET Core Web Application (.NET Core) and in project.json making.NET461 the only target Framework

It's the same thing as making an ASP.NET Core Web Application (.NET Framework) project. The type of project between the two is determined by the .csproj file and you changed it in your .csproj from targeting .NET Core to targeting the .NET Framework. In previous release/beta versions of ASP.NET Core it was possible to have both Frameworks in a project.json file (which has been replaced by a simplified .csproj file in .NET Core 2.0 which more .NET developers are familiar with) but you could only publish to one.

just creating a ASP.NET Core Web Application (.NET Framework) project which only includes.NET461 by default.

Are there other difference that I am not aware of like the way the the projects are published, etc If you target the .NET Framework and not .NET Core your app cannot be cross platform and your app can only run on Windows and not Linux/Mac.

The reason for there being separate ASP.NET Core Web Application (.NET Core) and ASP.NET Core Web Application (.NET Framework) is because the latter allows you to make use of functions, packages or 3rd party libraries that are dependent on Windows and the same .NET Framework or higher will be required to be installed on the machine.

The former doesn't have the .NET Framework requirement but allows your app to be cross platform and when you publish your app it publishes all the dependent .NET Core dll files to the publish directory in that way circumventing the .NET Framework installation requirement.

It will also affect compilation as if you target .NET Core and make use of a Windows specific function or package you will get a compilation error.

You can easily switch between the two by adjusting your .csproj to target the one or the other.

Microsoft Docs

You should use .NET Core for your server application when:

  • You have cross-platform needs.

  • You are targeting microservices.

  • You are using Docker containers.

  • You need high performance and scalable systems.

  • You need side by side of .NET versions by application.

You should use .NET Framework for your server application when:

  • Your application currently uses .NET Framework (recommendation is to extend instead of migrating)
  • You need to use third-party .NET libraries or NuGet packages not available for .NET Core.
  • You need to use .NET technologies that are not available for .NET Core.
  • You need to use a platform that doesn’t support .NET Core.

Update (2018/10/30)

It has been announced that ASP.Net Core 3 which has a release date in 2019 Q1, will only support .NET Core and NOT .NET Framework

As announced on the .NET Blog earlier this month, .NET Framework will get fewer of the newer platform and language features that come to .NET Core moving forward, due to the in-place update nature of .NET Framework and the desire to limit changes there that might break existing applications. To ensure ASP.NET Core can fully leverage the improvements coming to .NET Core moving forward, ASP.NET Core will only run on .NET Core starting from 3.0. Moving forward, you can simply think of ASP.NET Core as being part of .NET Core.

Customers utilizing ASP.NET Core on .NET Framework today can continue to do so in a fully supported fashion using the 2.1 LTS release. Support and servicing for 2.1 will continue until at least August 21, 2021 (3 years after its declaration as an LTS release) in accordance with the .NET Support Policy.

Solution 2

First see the difference in project.json files when you create ASP.NET Core Web Applications targeting different frameworks.

difference between asp.net core with different frameworks

As per your question, if you change the framework in ASP.NET Core Web Application(.NET Core) project.json only to have net461 and save, it'll restore the packages and will give the following error.

enter image description here

If you remove Microsoft.NETCore.App dependency and saves the file, It'll again restore the dependencies and won't give any error.

If you notice the first image, this has finally become a ASP.NET Core Web Application with .NET Framework.

Solution 3

I was confused at first as well. The main difference is that ASP.NET Web Application (.NET Framework) is the normal asp.net that we have been using. It contains App_Start folder web.config, Global.asax etc.. (Like MVC5,You get the idea..).

Whereas ASP.NET Core Web Application (.NET Framework) is a core framework(MVC6). (Not dependent on System.Web). Brand new project.json.. startup.cs and program.cs etc... And it supports all the old libraries of .net framework as well.

Share:
33,416
Blake Rivell
Author by

Blake Rivell

I am a .NET developer who builds custom web applications for businesses. I have a very strong passion for what I do. My hobbies are video games and fitness.

Updated on July 08, 2022

Comments

  • Blake Rivell
    Blake Rivell almost 2 years

    With the release of .NET Core RC2 Microsoft made it so there are now 3 Web Application templates:

    • ASP.NET Web Application (.NET Framework) — The old
    • ASP.NET Core Web Application (.NET Framework) — the new, to be hosting on Windows only
    • ASP.NET Core Web Application (.NET Core) — Linux, OSX, Windows

    I am trying to use the new Core Web Application template but without trying to target Linux, OSX, Windows so it seems like the ASP.NET Core Web Application (.NET Framework) is perfect for me. It took me a while but I learned that in order to add a class library that will work with this project type you need to add a Class Library (.NET Core) and change the frameworks section to only be net461 to match the Web Application.

    "frameworks": {
        "net461": { }
    }
    

    My Question:

    What is the difference between creating an ASP.NET Core Web Application (.NET Core) and in project.json making net461 the only target framework

    and

    just creating an ASP.NET Core Web Application (.NET Framework) project which only includes net461 by default.

    Are there other differences that I am not aware of like the way the projects are published, etc.?