Running ASP.NET Applications in Debian and Ubuntu using XSP and Mono
Posted by Admin on November 10th, 2006
Mono has a fully functional implementation of ASP.NET. This includes full support for ASP.NET Web Forms and Web Services. This essentially means that more or less any ASP.NET application that you have developed using with the .NET Framework will work with Mono. Obviously there might be changes needed, such as data access changes, removal of any
reliance on .NET Framework BCL types that are not implemented in Mono yet, and also the removal of any code that makes
use of platform invoke and so on. At this stage the ASP.NET support in Mono can be considered as excellent and a lot of
publicly available web applications already make use of Mono’s ASP.NET support.
when using ASP.NET with Mono you have two options as regards which web server to host your ASP.NET applications that is XSP and Apache we are using here XSP.
XSP
XSP is a “light-weight web server” capable of hosting and serving ASP.NET applications. It is written using C#, making extensive use of the classes in the System.Web namespace.XSP web server runs on both the Mono runtime and also on the .NET runtime.
Now we are going to take a look how to install XPS and mono for ASP.NET applications and testing this setup
First thing is you need to install mono
Install mono in Debian
If you want to install mono in your debian system you need to run the following command
#apt-get install mono mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol
You can can see in this screen which will install all the required packages

Install mono in Ubuntu
If you want to install mono in your Debian system you need to run the following command
sudo apt-get install mono mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol
Install XSP Web server in Debian
If you want to install ASP.NET2.0 version use the following command
#apt-get install mono-xsp2 mono-xsp2-base asp.net2-examples
If you want to install ASP.NET1.0 version use the following command
#apt-get install mono-xsp mono-xsp-base asp.net-examples
This will install all the required development environment and sample applications
Install XSP Web server in Ubuntu
If you want to install ASP.NET2.0 version use the following command
sudo apt-get install mono-xsp2 mono-xsp2-base asp.net2-examples
If you want to install ASP.NET1.0 version use the following command
sudo apt-get install mono-xsp mono-xsp-base asp.net-examples
This will install all the required development environment and sample applications for ASP.NET
Test ASP.NET Applications
We have already installed sample applications
If you want to run ASP.NET 2.0 application you need to go to /usr/share/asp.net2-demos/ run the following command
#xsp2
This will start the XSP with ASP.Net 2.0 application
xsp2
Listening on port: 8080 (non-secure)
Listening on address: 0.0.0.0
Root directory: /usr/share/asp.net2-demos
Hit Return to stop the server.
Application_Start
Now you need to point your web browser to http://localhost:8080/
You should seen the following screen

If you want to run ASP.NET 1.0 application you need to go to /usr/share/asp.net-demos/ run the following command
#xsp
This will start the XSP with ASP.Net 1.0 application
xsp
Listening on port: 8080 (non-secure)
Listening on address: 0.0.0.0
Root directory: /usr/share/asp.net-demos
Hit Return to stop the server.
Application_Start
Now you need to point your web browser to http://localhost:8080/
You should seen the following screen

If you want to know more options available for XPS check here
Possible errors
If you get the following error when you point http://localhost:8080/
Error Message: HTTP 404. File not found /usr/share/asp.net2-demos/index2.aspx
Solution
You need to copy the index.aspx to index2.aspx
For Debian Users
#cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx
For Ubuntu Users
sudo cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx

December 3rd, 2006 at 2:31 pm
Hi,
Great sample I am using Ubuntu and this helped a lot. My issue is that when I try to run the http://localhost:8080/ I Get the following:
Server error in ‘/’ application
File ‘/’ not found.
Description: Error processing request.
Error Message: HTTP 404. File ‘/’ not found.
I also used the sudo cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx
with same results.
Any help would be appreciated
Thanks
David…….
December 3rd, 2006 at 6:38 pm
if you install asp.net version 1 documents you should be able to see the test page
February 13th, 2007 at 4:22 pm
Any ideas how to make apache2 and mono work together? mod_mono ? Do ya know how to configure them?
July 3rd, 2007 at 7:42 pm
Another option is the Neokernel, there is a release for Mono of the
Neokernel Web Server at http://www.neokernel.com, it’s easier to run ASP.NET with
the Neokernel than with XSP or apache/mod_mono.
February 23rd, 2008 at 9:08 am
To David:
– i think i’m late on posting this
You must be on the directory /usr/share/asp.net2-demos/ before you run xsp. Otherwise that error will be displayed.
Please take note this when you run xsp, you should see the Root directory: /usr/share/asp.net2-demos/
HTH.
March 31st, 2008 at 1:51 am
Hi all. First of all, thank you for this excellent tutorial. I have an asp.net 2.0 app that I used to run on IIS but I am trying t get it to work on Ubuntu with Apache. However, this app uses an MS access database and I cant put xsp to work with this. Any ideas?
March 31st, 2008 at 3:58 am
To pepesmith: Your solution worked perfectly fine for me. Thanks
I am getting index2.aspx not found error now.
March 31st, 2008 at 4:02 am
It’s working now!!! Here is the solution for Ubuntu users:
sudo cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx
I got this solution from a blogger in another site.
June 12th, 2008 at 10:30 am
I installed Ubuntu 7.10 with PHP and mySQL and also installed mono for ubuntu (both, xsp1 and xsp2) with examples/demos.
When running xps or xps2 I seem to get the predicted responses.
However when going to http://localhost:8080/ the following is displayed in the browser in either case:
Server Error in ‘/’ Application
File ‘/’ not found.
Description: Error processing request.
Error Message: HTTP 404. System.Web.HttpException: File ‘/’ not found.
Stack Trace:
System.Web.HttpException: File ‘/’ not found.
at System.Web.StaticFileHandler.ProcessRequest (System.Web.HttpContext context) [0x00000]
at System.Web.HttpApplication+c__CompilerGenerated2.MoveNext () [0x00000]
12/06/2008 7:44:25 AM
—————————————
what went wrong? Mind you, I am also quite new to Linux and ubuntu in particular and can do with all help I can get.
Cheers, Gerd
July 26th, 2008 at 2:15 pm
I have the same error….
September 29th, 2008 at 10:04 pm
I build a website in ASP.net that works perfectly in a windows server. I need to migrate this website to a linux server, which dont have the Mono. I’m going to suggest these application to my co-workers, but i have a doubt: do i have to change anything on my code source? Or the files i have now will just work fine?
Tks
March 9th, 2009 at 10:36 am
Server Error in ‘/’ Application
Standard output has not been redirected or process has not been started.
Description: HTTP 500. Error processing request.
Stack Trace:
System.InvalidOperationException: Standard output has not been redirected or process has not been started.
at System.Diagnostics.Process.CancelErrorRead () [0x00000]
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:CancelErrorRead ()
at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000]
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.CodeDom.Compiler.CompilerParameters options) [0x00000]
at System.Web.Compilation.AppCodeAssembly.Build (System.String[] binAssemblies) [0x00000]
at System.Web.Compilation.AppCodeCompiler.Compile () [0x00000]
at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00000]
Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42
March 28th, 2009 at 7:24 pm
I got the same problem for normal aspx files on my Debian system.
I also installed the VNBC compiler with apt-get install.
A test file with this content started working:
—-SNIP—-
TEST
—-SNIP—-
I’m wondering why the C# compiler has got such problems while the VB compiler is running well?
March 28th, 2009 at 7:25 pm
Okay, the test file content in my previous commit has been crippled, here again:
<%@Page language=”vb” %>
<html>
<body>
<%
Response.Write (“Hello world”)
%>
TEST
</body>
</html>
May 3rd, 2009 at 12:27 pm
June 17th, 2009 at 10:01 pm
Kitt, thanks! this worked great with me at the point when I was almost about to give it up
June 30th, 2009 at 10:33 am
Rather than create a symlink it is best to install mono-devel to resolve this issue.
Either:
sudo apt-get install mono-devel
or:
apt://mono-devel