Create and run ASP.NET applications on Linux using Mono.
What is Mono?
Mono provides the necessary software to develop and run .NET client and server applications on Linux. It can also be deployed on Solaris, Mac OS X, Windows, and Unix. Mono is dual licensed by Novell, similar to other products such as Qt and the Mozilla Application Suite. Sponsored by Novell, the Mono open source project has an active and enthusiastic contributing community and is positioned to become the leading choice for development of Linux applications.
- Based on the ECMA/ISO standards
- Runs ASP.NET and Winforms applications
- Can run .NET, Java, Python and more
- Open Source, Free Software
Now we come to the main essence of this article, i.e running ASP.NET applications on Linux.
This article assumes that Mono is installed on your Linux system. If it is not installed you can download from http://www.mono-project.com/Downloads
Now, lets get started building our first ASP.NET Application using Mono XSP
First of all let's create a folder or directory to store the ASP.NET files and change to that directory. You can create the directory in your home directory.
Type in the following commands at prompt to do the same
Will create a directory aspdotnet
Will change to directory aspdotnet
Now we will create a simple application that will display a message on click of a button to greet a user who has entered his name in the given text box.
For this we will create a ASP.NET page
Type in the following code in greet.aspx using your choice of Editor (e.g. vi greet.aspx)
Begin of code greet.aspx
<%@ Page language="c#" src="greet.aspx.cs"
Inherits="GreetApp.GreetPage" AutoEventWireup="true" %>
<title>ASP.NET on Linux</title>
Enter your name: <asp:TextBox id="name" runat="server" />
<asp:Button id="greet" Text="Greet" onClick="OnGreetClick" runat="server"/>
<br /><strong><asp:Label id="message" runat="server">Mono Power
End of code greet.aspx
Type in the following code in greet.aspx using your choice of Editor (e.g. vi greet.aspx.cs)
Begin of code greet.aspx.cs
public class GreetPage : System.Web.UI.Page
protected Label message;
protected Button greet;
protected TextBox name;
public void OnGreetClick(Object sender, EventArgs e)
message.Text = "Congratulations, " + name.Text + "You are running ASP.NET On Linux ";
End of code greet.aspx
After saving the above files, type xsp at the command prompt to start the Server.
Now open a web browser, type the url http://localhost:8080/greet.aspx and press ENTER. You should see a web page with a text box and a message. Enter a name in the text box and click the "Greet" button.
Welcome to the world of Mono.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.