Sunday, 10 February 2008

My first little ASP.net project using the Mono XSP server

I wanted to provide an online version for the project Delphi2C#, so that people can just paste their Pascal code on the website, and see how good the converter is for them when it displays the C# version of their code.

On Debian, you need to install:
apt-get install mono-xsp asp.net-examples
This will give you a file
/etc/xsp/debian.webapp
It already contains the configuration for the samples, that live in
/usr/share/asp.net-demos
To start the xsp server, you just run
/etc/init.d/mono-xsp start
And you will be able to access the samples at
http://YOURSERVER:8081/samples
For example to add your own aspx file, copy it to
/usr/share/asp.net-demos/DelphiNet2CSharp.aspx
The source code of that file you can see here:
Browse CVS of Delphi2C#

If you have a dll as well, copy that to
/usr/share/asp.net-demos/bin/Delphi2CSharp.dll
In your aspx file, you need to write at the top to use that dll:
<%@ Import Namespace="Delphi2CSharp" %>
To debug your application (e.g. I had compiled the DLL for .Net 2.0, but the xsp only supported 1.1 and crashed without any message to the browser):
cd /usr/share/asp.net-demos
MONO_OPTIONS=--debug && xsp --verbose
Then in the webbrowser go to
http://YOURSERVER:8080/DelphiNet2CSharp.aspx 
You will see all the Console.WriteLine output, and also any exceptions and Mono crash messages.

No comments: