Search code examples
.netasp.net-core.net-coreshared-hosting

Host .Net Core 2.2 web api on Server with .Net framework installed


I have written a .NetCore 2.2 Web API for a client, but since found out that the server I will be hosting this API on does not support .Net Core 2.2, but does have .Net Framework 4.7.2 installed on it.

The client is not prepared to upgrade their hosting package.

Is it possible to host a .Net Core app on a Windows server which does not have .Net Core installed, but does have the .Net Framework isntalled?

I have done some reading, but I am not findin a post directly related to my requirements.


Solution

  • In 1.x and 2.x, yes. ASP.NET Core is compatible with .NET Standard, which means it's also compatible with .NET Framework (4.6.1+ for ASP.NET Core 2.x). You simply need to edit the csproj file and change the target framework:

    <TargetFramework>net472</TargetFramework>
    

    However, it's worth noting that ASP.NET Core 3.x no longer supports targeting .NET Framework. It's only compatible with .NET Standard 2.1, which is not compatible with any version of .NET Framework. As such, you will be stuck at 2.2.