2

I am trying to run an application made in .NET Framework 4.5 (Windows) in a Linux environment (Centos7).

I have tried with mono and xsp4 but I have the following doubts:

  • Mono and xsp4 are the best applications to execute a code in .Net?
  • Should I compile the * .cs first in linux?
  • Can I run the publish folder generated in windows directly in Linux (if so)?
  • I can run an application made in .net in asp.net

regards

ayar
  • 143
  • 1
  • 5
  • 19

1 Answers1

4

Applications written for the standard .NET framework will not run in Linux; you can try to run them in Mono but it has a number of restrictions in terms of what it supports. If you want to guarantee support it would probably be better to compile your app with Monodevelop so it will compile against that runtime. It is also the "old" way of doing this.

What you should be doing is targeting .NET Core; which is designed to run on other operating systems (including a number of Linux distributions). When you do that you would add a runtime identifier for your distro and publish to it; generating binaries that will run with the dotnet command on that platform.

Note that when using .NET Core in production you need to set up a reverse proxy to a "production ready" webserver like IIS, Apache, or Nginx as those are hardened against attacks the Kestrel server still is not.

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
  • Totally agree but remember "it's not recommended to use dotnet run to run applications in production" https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run?tabs=netcore2x , I assume that you need to hide it behind some like else eg NGINX (https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.1&tabs=aspnetcore2x) or Apache (https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-2.1&tabs=aspnetcore2x) ..... But I have never done this.... – Angus Connell Apr 20 '18 at 15:47
  • @AngusConnell Correct; you need to set up a reverse proxy with a production ready webserver. I have done it with IIS (obviously not available on Linux); its pretty easy. – BradleyDotNET Apr 20 '18 at 15:49