Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy ASP.NET MVC on Linux: Best Practices, Tools & Surprises

I'm wondering about best practices to develop ASP.NET MVC apps with an option to deploy on Linux. If you are creating these kinds of MVC apps,

  • What Linux/Mono platform are you targeting?
  • How much of the development are you doing on Windows and how much on Linux?
  • Are you using an ORM to abstract the database? Which one?
  • Are you running a build engine on Linux? What about tests?
  • What other tools are you using?
  • How much additional work has it been to target Linux in addition to Windows?
  • What ugly or pleasant surprises have you encountered?
like image 926
keithm Avatar asked Jul 23 '09 15:07

keithm


People also ask

Can ASP NET MVC run on Linux?

ASP.net mvc5 Project can't be deployed on Linux. However if you want to deploy it on linux, First you have to convert it into . net Core MVC Project. ASP.NET Core is available on Windows, Mac, and Linux.

Can we host ASP Net website on Linux server?

ASP.NET can run on both Windows servers and Linux servers. So, don&'t feel confined to a Windows host, although Windows hosting services will be optimized for ASP.NET websites and applications. Your host will need an SQL server database, such as MySQL, to be able to host applications built using ASP.NET.

Can you develop ASP net in Linux?

There are alternatives though, and today it is possible to fully develop an ASP.NET Core application outside of Windows. In this blog post we will be looking into that, specifically in Linux. Please note that all of the tooling described here is cross-platform all of this will work on any platform that supports .


2 Answers

The company I work for targets Mono on Linux as our main deployment environment. Thus there is no "additional" work - we provide the whole stack, from hardware, through operating system (customized and trimmed) to applications. Using Open Source gives huge savings for us and our clients (and yes, we do contribute back to the OS Projects we rely on).

The important thing is to constantly test using your actual target (sorry, Mono on Windows doesn't count). Sure, developers use Visual Studio, but the continous integration (using CruiseControl.Net, you'll need Mono 2.4.2 to run it on Linux) is done both on Windows and Linux, testing all Mono versions we expect to work on (it got much more stable recently, but still, regressions do happen between releases). It's quite easy to run parallel Mono versions on one *nix system, you can even include an svn snapshot build if you prefer to catch upstream regressions early. If you don't roll out your own distribution, then remember that most Linux vendors ship Mono with custom patches - this has caused problems for us before. Also, many distributions have a lot of lag updating Mono, and this is a rapidly advancing project.

For database layer we use mostly "plain" ADO.NET - Oracle (with dotConnect for Oracle, they support Mono) and SQLite (Mono ships with a working connector). I have also used the official ADO.NET Driver for MySQL (Connector/NET) and it, too, works well. ORM mappings are more tricky, but NHibernate is usable (keep in mind that they do not support Mono officially).

As for the build engine and tests - NAnt and NUnit are well known and well tested. With most recent versions of Mono xbuild (clone of MSBuild) actually got usable, but prepare yourself for contributing quite a lot patches if you decide to use it for more complex scenarios.

Write tests. Lots of them. Be prepared to contribute patches and bugreports, and if you use commercial components - make sure the supplier officially supports Mono.

like image 95
skolima Avatar answered Oct 14 '22 13:10

skolima


Nathan Bridgewater's blog has some nice articles showing, among other things:

  • running MVC3 with razor on mono
  • migrating ASP.NET MVC from Windows/SQL Server to Linux/MySQL
  • installing and running MonoDevelop
  • installing mono from source

http://iws.io/get-mvc3-razor-running-on-mono/

like image 36
Drew Noakes Avatar answered Oct 14 '22 11:10

Drew Noakes