Run ASP.NET application on Linux

3.4k Views Asked by At

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

1

There are 1 best solutions below

2
On

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.