Thursday, August 23, 2012

Basic asp.NET dev environment in Ubuntu 12.04

I recently had to do a small example of integrating the system I am currently working on into an asp.NET application.  Not having a windows machine handy I though I would give Mono a try.  Fortunately setting up a basic dev environment was really simple.  NOTE: this is a very basic dev environment with no IDE or frameworks installed etc, it was perfect for what I needed but may not be appropriate for full blown development.

First install xsp2:

sudo apt-get install mono-xsp2

then:

mkdir -p ~/dotnet

cd dotnet

gedit Default.aspx

Then paste in the following:


<%
    HelloWorldLabel.Text = "Hello, world!";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label runat="server" id="HelloWorldLabel"></asp:Label>
    </div>
    </form>
</body>
</html>



now save the file and go back to the terminal and run:

xsp2

*Note: this must be run in the directory where you created the file.

Now open a browser and visit:
http://127.0.0.1:8080/Default.aspx

And that's it.  This is a very basic dev environment and is probably not suitable for a full blown application but it was perfect for my needs.

No comments:

Post a Comment