Skip to main content

How to set up ASP.NET with Mono on your fresh Karmic Koala Ubuntu installation

Yup, I admit it. I am a die hard .NET fan. 

And I am very exited about the mono project.

And because I migrated from the MS world to the Linux world I know what people accustomed to .NET & Windows development world expect: 

Step by step tutorials. 

And here is now one I want to share with you. 

Setting up a fresh Ubuntu so you are ready to go with your ASP.NET application. You will still need to understand ASP.NET, you will still need to take care about specific porting problems of your application, but this can be understood as a general Getting Started:
I reproduced these steps on a clean Karmic Koala installation, so it might be different with other versions of Ubuntu.

_________________________________________________

Step By Step Guide to setting up ASP.NET on your Ubuntu Karmic Koala with Apache

Komplettes aufsetzen von Mono und ASP.NET auf Ubuntu (Karmic)

Useful sites that you might need sooner or later:
http://mono-project.com/AutoHosting
https://help.ubuntu.com/community/ModMono
https://bugzilla.novell.com/show_bug.cgi?id=434931#c59
https://help.ubuntu.com/community/ModMono

Most of the info ive written here comes from one of theses sites. If youve got problems, looking at them will probably give you some clues what you need to do.


First go to the commandline and install some packages by doing the folowing:
> sudo apt-get install mono-gmcs mono-gac mono-utils monodoc-browser monodevelop-nunit monodevelop-versioncontrol mono-xsp2 mono-xsp2-base asp.net2-examples

Test if its running so far:

> cd /usr/share/asp.net2-demos

add/change the web.config there to correspond to this:


<system.codedom>
<compilers>
<compiler
language="c#;cs;csharp"
extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider, System,
Version=2.0.3600.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
compilerOptions="/optimize"
warningLevel="1" >
<providerOption
name="CompilerVersion"
value="v3.5" />
</compiler>
</compilers>
</system.codedom>



on the shell start xsp2 by calling:

> xsp2

Now see if its working:

go to http://yourserver.org:8080 via your browser and look if there is a shiny ASP.NET website.


Yes? Good. If not, its time to look at the sites I posted at the beginning of this tutorial.


Install Apache and configure it to run with Mono :
Do some commandline installation magic:
>sudo apt-get purge apache2 apache2.2-common
>sudo apt-get autoremove
>sudo apt-get install apache2 apache2.2-common
>sudo a2enmod mod_mono_auto
>sudo /etc/init.d/apache2 restart

create a simple testsite and put it somewhere where apache can see it. default location on debian/karmic would be:
/var/www/

so for example create a testpage there:
/var/www/test.aspx

with the following content:

<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
  <title>ASP Test Page</title>
  </head>
  <body>
  <form id="form1" runat="server">
  <asp:label id="lbl1" runat="server">ASP Test Page -Can you read me?</asp:label>
  </form>
  </body>
</html>



  
open your browser again and go to:
http://yourserver.org/test.aspx

if you can read the website:
congratulations! you just installed an AutoHosting ASP.NET with mono and Apache!

If you are able to see the website, the next steps are easy:
Create  or open your web application with the monodevelop IDE .
wenn du sie siehst erstelle deine web application mit monodevelop.

Compile it.
You can create it with visual studio if you want and then compile it with monodevelop. But the important part is to compile it with monodevelop! Mono should be able to run windows compiled pages as well, but nevertheless I found it useful for ruling out errors just using Mono-compiled apps. A sidenote: Dont use any fancy-shmancy .NET 3.0 stuff or new web controls. stick with simple ones already present in visual studio 2003 or 2005 if you want to get your site up and running quickly.

So you compiled the stuff? Alrite. Now just brutally copy the whole contents of the solution folder to /var/www

(of course not all is needed but for this startup, just copy all stuff)

Check to make sure that now after the copying the default aspx site you want to to load resides really in  /var/www.

Finally, fire up the browser again. open your default web-page and feel

The Linux Way Of ASP.NET!

happy coding!

Comments