Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Porting ASP.NET application to Mono/Apache under Linux

I've got a relatively small ASP.NET project that was written using C# 4.0.

I was wondering if anybody had managed to port such a project over to running under a webserver on Linux, the latest information I can find appears to only have support for ASP.Net 2.0 - Configuring and running Mono ASP.NET 3.5 (AJAX.NET) on Linux computers

The project uses LINQ-to-SQL for the entire data access layer, and I know Mono itself support LINQ, so I thought it stands to reason that it should work.

I just want to know if it's a complete waste of time or not before starting.

Thanks.

like image 824
Ryan Weir Avatar asked Dec 23 '11 03:12

Ryan Weir


People also ask

Can I run ASP mono on Linux?

Mono can be run on Linux, BSD, UNIX, Mac OS X, Solaris and Windows operating systems. With Apache mod_mono we can run ASP.NET with C# on Linux machine. Mono is not just an ASP.NET interpreter, it also build a windows form and run on Linux, BSD, UNIX, Mac OS X, Solaris and Windows operating systems.

What is mod_mono in ASP NET?

ASP.NET hosting with Apache The mod_mono Apache module is used to run ASP.NET applications within the Apache web server. The mod_mono module runs within an Apache process and passes all the requests to ASP.NET applications to an external Mono process that actually hosts your ASP.NET applications.

How do I run an ASP NET application in Apache?

The easiest way to run Asp.Net application is using You can read more about AutoHosting here or manual hosting configuration here, for ubuntu user please refer to this documentation. Save the file and restart your Apache. Now let’s start write the first Asp.Net application.

What is the best way to deploy a mono application?

For deploying applications, we recommend the use of the mod_mono or FastCGI approaches, as that will give you all the configuration options and flexibility that come with using Apache or a FastCGI server. For quickly getting started, get familiar with Mono and ASP.NET, XSP is the ideal solution.


2 Answers

I run an ASP.NET 4.0 application on Suse Linux using mono. My experience with mono is that it just works. My app is ~ 15.000 LOC and uses third party components like mongo-csharp-driver, lucene.net, elmah, munq, and sphorium.webdavserver.

I've had almost no compatibility problems during development - and the ones I had where easily worked out (for example sphorium accesses the registry; this obviously works different on Linux/Mono). I've even started developing with Visual Studio instaed of MonoDevelop and without the Mono plugin, because Visual Studio is a better IDE, and it just works when I compile my web app on linux and deploy it on Apache (even though I develop with .NET on Windows).

I've written a short blogpost on getting started with the setup

like image 158
Maate Avatar answered Sep 23 '22 06:09

Maate


This is definitely not a waste of time. The company I work for converted our VB.Net application to C# so that it can run under mono. This application has over 200k lines of code. We now are running with Ubuntu/Apache/Mono/Postgresql on Amazon ec2.

The only concern I would have is with your database. If it is MS SQL then you will need to look at migrating to MySQL or Postgresql. Again we did this with 300+ tables and 900 stored procedures. It is definately something worthwhile in the long run.

I think that the best way to get started would be to setup a local environment running something like Ubuntu. You can get the near latest versions of mono from the repositories at http://badgerports.org/ or if you prefer you can the latest versions as build scripts which are maintained here. Install monodevelop and build your code on linux with mono. From experience the mono with C# is a pretty much a complete implementation of the .net framework. I would be surprised if there was something in your application that is yet to be implemented in mono.

I have an answer here showing an easy configuration for your application under apache. I use this configuration for mono applications running on Ubuntu.

like image 28
startupsmith Avatar answered Sep 20 '22 06:09

startupsmith