Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

July 22, 2006

Create ASP.NET 1.0 & 2.0 Applications On GNU/Linux and Windows Using Mono XSP

Filed under: GNU/Linux, Gentoo, Mono, Web — tabrez @ 12:39 pm

This post assumes that Mono is installed on your system. The following links should help if it is not installed.

Installing Mono on Gentoo and Ubuntu 5.10
Installing Mono and XSP on Ubuntu 6.06
Installing Mono and XSP on Fedora

Installing Mono XSP on Gentoo

#emerge xsp xsp2

Installing Mono XSP on Debian/(K)Ubuntu

#sudo apt-get install xsp xsp2

Installing Complete Mono Environment(Mono, GTK#, XSP) on MS Windows

  1. Download the Mono installation file for MS Windows from the Mono website.
  2. Run the installer and follow the installation wizard.

Go to the Mono menu in the Start menu(Start->All Programs->Mono[version]) to access all the applications installed as part of Mono.

Your First ASP.NET 1.0 Application Using Mono XSP

  1. First create a directory to store the ASP.NET files and change to that directory. You can create the directory in your home directory.
    sh# mkdir aspnet && cd aspnet
  2. Create a sample ASP.NET page. Copy and paste the following code in two separate files(hello.aspx and hello.aspx.cs).
    hello.aspx
    HTML:
    1. <%@ Page language="c#" src="hello.aspx.cs"
    2.                     Inherits="HelloApp.HelloPage" AutoEventWireup="true" %>
    3.     <title>First Mono ASP.NET 1.0 Application</title>
    4.   </head>
    5.     <H1>Welcome to my page!</H1>
    6.     <form  runat="server">
    7.       Enter your name: <asp:TextBox id="name" runat="server" />
    8.       <asp:Button id="greet" Text="Greet" onClick="OnGreetClick" runat="server"/>
    9.     </form>
    10.     <br /><strong><asp:Label id="message" runat="server">Hello, World!
    11.             </asp:Label></strong>
    12.   </body>

    hello.aspx.cs
    C#:
    1. using System;
    2. using System.Web.UI.WebControls;
    3.  
    4. namespace HelloApp
    5. {
    6.    public class HelloPage : System.Web.UI.Page
    7.    {
    8.       protected Label message;
    9.       protected Button greet;
    10.       protected TextBox name;
    11.  
    12.       public void OnGreetClick(Object sender, EventArgs e)
    13.       {
    14.           message.Text = "Hello, " + name.Text;
    15.       }
    16.    }
    17. }

  3. From the same directory('aspnet'), start the XSP server:
    sh# xsp

    (you can press ENTER to terminate the XSP server process)

  4. Open a web browser, type the url http://localhost:8080/hello.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 to see the personalised greeting displayed.

On MS Windows, go to the Mono menu in the Start menu(Start->All Programs->Mono[version]), select "Mono[version] Command Prompt" menu item. Create a directory(say 'c:\programs\aspnet'), change to that directory and copy the above two files in that directory. From the same directory, run 'xsp' commad to start the XSP webserver. Open a web browser and access the url http://localhost:8080/hello.aspx.

Your First ASP.NET 2.0 Application Using Mono XSP

To develop ASP.NET 2.0 applications using Mono XSP server, start 'xsp2' webserver instead of 'xsp'. Create a test ASP.NET 2.0 page(say 'hello2.aspx') and copy it in a folder. Run the following command from the same folder:

sh# xsp2

Go to http://localhost:8080/hello2.aspx to test the ASP.NET 2.0 page.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Installing C#, Mono(.NET) & MonoDevelop in Ubuntu Dapper Drake 6.06
  • Installing C#/Mono(.NET)/MonoDevelop/XSP in Ubuntu Gutsy Gibbon(7.10)
  • Writing Your First Program With Mono And MonoDevelop
  • C# & MonoDevelop (.NET) on Gentoo and Ubuntu
  • My Favourite Note-Taking Applications
  • GNU/Linux Users vs Rest of the world :)
  • Creating “Hello World” Web Application Using the Grails Framework

  • Readers who viewed this page, also viewed:


    6 Comments »

    1. Will this work with VisualBasic as while?

      Quote

      Comment by Myles A. Braithwaite — July 25, 2006 @ 7:17 pm

    2. Report from OSCON2006: The Ruby Conspiracy, Other stuff......

      Report from OSCON2006: The Ruby Conspiracy
      Software Development Amidst the Whiz of Silver Bullets... -......

      Quote

      Trackback by Hulkster — July 27, 2006 @ 5:12 pm

    3. There still are some rough edges when it comes to developing ASP.NET applications using VB.NET. You can certainly give it a try but you may or may not get the results: the errors the VB.NET compiler sometimes produces are very irritating.

      VB.NET support is being developed at a fast pace though. Until the time it becomes a bit more stable, the best way would be to manually compile the VB.NET code-behind file to a 'dll' file and then use it from the ASPX file('C#' should be specified as the language being used; it doesn't matter with IL being present in the dll). If you find the VB.NET compiler that comes with mono('mbas') not upto the task, then use a Windows machine to create the dll files and copy them over to the GNU/Linux box. Not an ideal way to develop web applications, but works for now.

      Quote

      Comment by tabrez — July 28, 2006 @ 4:54 pm

    4. Your First ASP.NET 2.0 Application Using Mono XSP
      Create a test ASP.NET 2.0 page(say 'hello2.aspx') and copy it in a folder.

      How about giving us working 2.0 files to test?

      Quote

      Comment by 2.0NOT — October 26, 2006 @ 12:54 am

    5. I always have terrible trouble with comment-related plugins that require me to put some line in the comment loop; I can never seem to find the right spot. Can anyone tell me where I should put the php line in my comments loop? I haven not modified anything much, and I would be very grateful. Thanks!

      Quote

      Comment by trmadol — January 25, 2007 @ 9:16 pm

    6. i think that the 'src' atribute is no longer supported in xsp2

      Quote

      Comment by eduardo osorio — June 21, 2007 @ 3:39 am

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost