Hello Mono
Wouldn’t it be cool to run .NET applications on Linux. Well, you can using Mono. Here is a quick setup guide for Debian users.
Add the following line to /etc/apt/sources.list and save
deb ftp://mirrors.kernel.org/debian/ unstable main
Update your sources
apt-get update
Install Mono
apt-get install mono
Install the Mono web server
apt-get install mono-xsp
Create a folder in /var/www called “aspnet”
mkdir /var/www/aspnet
Navigate to the new directory
cd /var/www/aspnet
Create a file called index.aspx (code listing below).
Create a file called index.aspx.cs (code listing below).
In /var/www/aspnet create a folder called “bin”
mkdir ./bin
Compile the files
mcs -r:System.Web.dll -target:library -out:bin/HelloWorld.dll index.aspx.cs
Configure the Mono web server
mono-server-admin.conf add --path=/var/www/aspnet --app=/aspnet
Use a browser to view the application. It should display “HelloWorld”
http://localhost/aspnet:8080
OR
http://xxx.xxx.xxx.xxx:8080
OR
http://www.yourdomain.com:8080
###index.aspx###
//index.aspx
<%@ Page language="c#" CodeBehind="index.aspx.cs" AutoEventWireup="false" Inherits="HelloWorld.Index" %>
<head>
<title>Debian asp.net HelloWorld!
</title>
<body>
<%= TestValue %>
</body>
</head>
###index.aspx.cs###
//index.aspx.cs
using System;
namespace HelloWorld{
public class Index:System.Web.UI.Page{
public string TestValue;
public Index(){
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Init(object sender, EventArgs e){
TestValue="HelloWorld";
}
}
}
Here is a <a href=”/images/HelloMono.jpg”>screen shot</a> of my Windows desktop accessing my Linux server running Mono. The “Hello World!” is generated by an ASP page running on Linux.
#Copyright 2004, 2005 Peter Magnusson (with a couple of additions by me)