Set up your first ASP.NET page on Linux

By Mithun Bose at January 25, 2010 06:23
Filed Under: .NET Framework, ASP.NET, MONO

Introduction

A few days ago I had a requirement to test and run a ASP.NET page on Linux on Mono .NET framework. Mono is an open source project led by Novell to create an Ecma standard compliant, .NET-compatible set of tools, including among others a C# compiler and a Common Language Runtime. Mono can be run on Linux, BSD, UNIX, Mac OS X, Solaris and Windows operating systems.

There are loads of documenation on MONO site and there are numerous configurations options available. In this post I've listed down the steps on how to quickly get your first ASP.NET page up and running on a Linux platform.

Steps

1) Install Mono Extension: If you are working on SUSE platform, you have to install Mono extension, you can download the evaluation or commercial package from here. SUSE platform comes with inbuilt MONO framework; however, this version of Mono is not built to be a platform to host ASP.NET and other .NET server applications. That's why you need to install the extension, which includes latest .NET features, such as ASP.NET 2.0 , AJAX, MVC and it can also be upgraded when new features of .NET becomes available in Mono.

The installation is very straight forword. Once you have downloaded the ISO file, run Yast to add this software. The full installation intructions is here.

2) Configure Apache to load Mono: Open the apache config file. The config file name is httpd.conf and it is usually in /etc/apache2 directory, add following line in httpd.conf

Include /opt/novell/mono/mod_mono.conf

The actual path to mod_mono.conf might vary depending on the distribution you use or the path where you installed apache.

Mod_Mono is an Apache module that provides ASP.NET support for the Apache web server. Click here if you interested in more details.

3) Configure the mod_mono.conf: The mod_mono configuration defaults to running the 1.0 runtime for applications, if you want to use the 2.0 runtime, you can just use the MonoServerPath directive to point to the 2.0 server, like this:

 

MonoServerPath "/usr/bin/mod-mono-server2"

4) Restart the Apache service: After changing the configuration files, you have to restart the apache service, use the following command:

apache2ctl restart

5) Copy or create the new ASP.NET website: You can copy or create simple ASP.NET page in the Apache2 www home directory. In my environment it is /srv/www/htdocs. You can find the settings in httpd.conf file. In this folder you can create a new folder names MonoTest.  So if you just copy and paste a simple ASP.NET hello world page to /srv/www/htdocs/MonoTest/. Assuming the hello world page file name is HelloWorld.aspx, then after you have copied the files browse to http://localhost/MonoTest/HelloWorld.aspx and you should see your first ASP.NET page up and running in the Linux platform.

The interesting fact is Mono can run sites which are precompiled using Visual Studio and there is no need to recompile in Mono.

6) Update the web.config file: A point to note is that mono only supports None or Forms Authentication mode and in Visual Studio the authentication mode defaults to Windows. So you probably have to update the setting in the web.config in case you getting authentication error in step 5, see following:

<authentication mode="[None|Forms]">

Comments

3/18/2010 4:00:26 PM #

Isaias Aiava

Resources like the one u noted here will be very useful to me! ill post a link to this site on my site.

Isaias Aiava United States |

3/18/2010 7:52:28 PM #

carbamide peroxide teeth whitening

u got a truly useful web log i've been  reading for around an hour.

carbamide peroxide teeth whitening United States |

3/20/2010 12:22:22 AM #

Fernando Brisbin

Very informative post. I've found your blog via Bing and I'm really glad about the information you provide in your posts. Btw your sites layout is really messed up on the Kmelon browser. Would be cool if you could fix that. Anyhow keep up the good work!

Fernando Brisbin Germany |

3/20/2010 12:06:21 PM #

Football highlights

I just couldnt leave your website before letting you know that I really enjoyed the useful information you offer to your visitors... Will be back soon to check up on new posts

Football highlights United Kingdom |

3/20/2010 9:57:21 PM #

Finanzportal

Always good to see, that was really a quality post. In theory I would like to write like this too. You need time to creat that excellent and additionally lots of effort to make such a brilliant article.

Finanzportal Germany |

3/20/2010 11:29:00 PM #

Crane Hire Liverpool

Hi  blog im from leeds but im moving to Liverpool i found this on the yahoo search engine, im in the crane hire company business keep the good work up i will add you to my favoroties.

Crane Hire Liverpool United Kingdom |

3/22/2010 12:18:00 AM #

watch southpark season 14 episode 4

There are for certain a batch of details like that to take into consideration

watch southpark season 14 episode 4 United States |

3/23/2010 4:48:41 AM #

top e-cig

u got a real useful web log I have been here reading for half an hour.

top e-cig United States |

3/23/2010 5:17:20 PM #

canon ef 50mm f/1.8 ii camera lens

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

canon ef 50mm f/1.8 ii camera lens United States |

About the author

I am a professional software developer based in London, England. I specialize in developing enterprise application and integration framework in C#, SQL Server, ASP.NET. 

My area of interests include SOA using WCF, Web, Business Intelligence and Database programming. I am a Computer Science Graduate and Microsoft Certified Professional Developer in enterprise application.