Thanks for posting your findings here, they saved me the time to do some research myself. I was about to start a thread regarding how the examples are not working on 14.1, while they were working on 14.0. The way I fixed them was by creating an instance of 14.0, downloading them from /usr/share (the folder is asp.net-demos) and then uploading them to /usr/share on the 14.1 instance.
In the spirit of "equivalent exchange", let me save you some time with my own findings with the appliance. I have had some success with my own ASP .net web applications, so I can provide some guidance on how to set yours up. (Sorry if this is months late, I just saw your post).
So, what kind of problems are you having with your ASP .net applications? I will attempt to address a few concerns that perhaps might help you, if they are unrelated please let me know and give me more details to see if I can provide with some pointers or help.
Let's begin with adding applications to the default application as "children" of it:
Open the file /etc/apache2/sites-available/000-default.conf (The directory /etc/apache2/sites-available is where the apache sites need to be added)
At the bottom of file, add the following lines (Change the values in bold with those of yours):
# For more information about mod_mono:
# http://www.mono-project.com/docs/web/mod_mono/
# Instruct Apache to to map the virtual path "/samples" to the physical path of the examples ("/usr/share/asp.net-demos"):
Alias /samples "/usr/share/asp.net-demos"
# Create an ASP .net application in the virtual path "/samples" mapped to the physical path of the examples ("/usr/share/asp.net-demos")
MonoApplications "/samples:/usr/share/asp.net-demos"
# Instruct Apache that everything in the virtual path "/samples" should be handled by mod_mono:
<Location /samples>
SetHandler mono
Require all granted
</Location>
Save the file and restart apache by executing (You need to execute this whenever you add a new ASP .net web application in apache but not when making changes to the any of the files inside the folder containing the Web Application, even cs files):
/etc/init.d/apache2 reload
Another way to accomplish adding a new application is the following:
Open the file /etc/mono-server4/debian.webapp
Add the following lines before the line </apps> (Change the values in bold for those of yours):
<web-application>
<!-- Name of the Web Application (It can be empty): -->
<name>samples</name>
<!-- Virtual Path of the Web Application: -->
<vpath>/samples</vpath>
<!-- Physical Path of the Web Application: -->
<path>/usr/share/asp.net-demos</path>
</web-application>
Save the file and restart apache by executing (Again, you need to execute this whenever you add a new ASP .net web application this way, but not when modifying files inside of the folder containg the Web Application):
/etc/init.d/apache2 reload
Now, let's replicate a common IIS behavior by having the default web application (the one that ships with the appliance) on port 80 and the examples on port 1080.
Open the file /etc/apache2/ports.conf
Add the following lines below the line "Listen 80", so Apache will be listening to the new port (Change the bold value in case you want to use a different port instead of 1080):
# Instruct Apache to listen to the following port:
Listen 1080
Save the file
Create the file samples.conf (or any other name you prefer, as long as it ends in .conf) inside the directory /etc/apache2/sites-available
Add the following content to the file (Change the values in bold with those of your own):
# Specify a virtual host to point to the Web Application:
<VirtualHost *:1080>
ServerAdmin webmaster@example.com
DocumentRoot "/usr/share/asp.net-demos"
# This part is not required if there is any other enabled site which specifies it:
<Location />
SetHandler mono
Require all granted
</Location>
Save the file
Enable this new site by executing the following command (If you used a different name than sample.conf, replace the bold value. Note that you don't need to specify the full path, regardless of the current path you are working on the terminal):
a2ensite samples.conf
Restart Apache by executing the following command:
/etc/init.d/apache2 reload
Once you follow these steps, you will be able to navigate to http://<Appliance's IP> and https://<Appliance's IP> and have the default web application included with the appliance launched. If you navigate to http://<Appliance's IP>:1080 (or the port you configured) you will navigate directly to the web application which you configured (if you didn't change any bold value, this would be the asp.net examples web application).
Figuring this out was a headache, and I must admit I didn't get this to work by just modifying /etc/mono-server4/debian.webapp (No, if you follow the instructions above you don't need to modify this file). Another thing to take in account is that in the mod_mono page of the mono project site (http://www.mono-project.com/docs/web/mod_mono/), the team recommends to use reload instead of restart, which is why the command provided in the instructions to restart Apache is reload and not restart.
If you desire to replace the default web application provided in the appliance, you have a few choices:
Use the existing /var/www directory: Add and delete files as needed so your web application is the one served through port 80 (http) and port 443 (https). This is the simpliest option, the TK way!
Create your own web application as detailed above and disable the default web application by using the following command:
a2dissite 000-default.conf
Modify the existing configuration so that it points to your own application by either:
Altering the /etc/apache2/sites-available/000-default.conf file so that the configuration points to your own web application (The configuration would look like the one presented above)
Altering the /etc/mono-server4/debian.webapp so that the path points to your own web application's directory
A few considerations:
The directory of your web-application that Apache points to needs to provide read (and maybe write) access to the Apache's account (www-data), this can be accomplished by either:
Having your web application be inside the /var/www or the /usr/share directories.
Executing the following commands (replace the bold values with your own):
# Grant access to the www-data to the web application's directory sudo chown -R www-data:www-data /usr/share/asp.net-examples
# Grant access to the "root" directory (the one containing your web application) to everyone so they can read it: sudo chmod -R 755 /usr/share
Mono's ASP .net implementation differs from Microsoft's, a crucial detail which can bite you is that Microsoft's implementation uses the precompiled DLL of your web application, while Mono's creates an automatically generated DLL prefixed with App_ which makes a reference to your precompiled DLL. This subtle difference has a few consequences:
You can make changes to files which contain code (cs, aspx, etc.) and these changes are picked up without the need to restart the web server (No need of an equivalent of an IIS reset).
Code which retrieves resources from the executing assembly will fail. This one is very important, since this is the reason why the Entity Framework 5 would not work: It seeks for resources in the executing assembly, those resources are packaged in your precompiled DLL, not in the automatically generated DLL prefixed with App_.
You might need to delete the pre-compiled DLLs and then copy the new pre-compiled DLLs into the bin directory of the web application in the appliance.
Mono's implementation of the .net framework is not complete yet and there might be a few differences, so you might need to check for what is implemented and what is not. The main advantage of Mono is that it is open-source and you can implement anything you need (if time allows you to do so), more since Microsoft has published the source code of the .net framework (so you could use it as a reference). I will post more about this in another thread, since I want some advice regarding what to do after modifying the source code, compiling it and installing it on an appliance.
Since Mono's implementation of the .net framework differs a little, it might make sense for you to install (not in your appliance, of course) MonoDevelop in a development environment (a virtual machine, for example), compile your code and use those assemblies (I really haven't had to do this myself, the only issue I came across was when using EF 5).
SignalR appears not to work with Apache (even though I saw a post which claimed it could be done if you built a development version, I was unable to get it working after following every step and spending at least two days on it).
You are not dealing with IIS, so you will need to refer a lot to how to configure Apache to behave the way you intended with an IIS configuration.
I hope that this helps you, please let me know if it does.
Thanks and equivalent exchange
Lorenzo,
Thanks for posting your findings here, they saved me the time to do some research myself. I was about to start a thread regarding how the examples are not working on 14.1, while they were working on 14.0. The way I fixed them was by creating an instance of 14.0, downloading them from /usr/share (the folder is asp.net-demos) and then uploading them to /usr/share on the 14.1 instance.
In the spirit of "equivalent exchange", let me save you some time with my own findings with the appliance. I have had some success with my own ASP .net web applications, so I can provide some guidance on how to set yours up. (Sorry if this is months late, I just saw your post).
So, what kind of problems are you having with your ASP .net applications? I will attempt to address a few concerns that perhaps might help you, if they are unrelated please let me know and give me more details to see if I can provide with some pointers or help.
Let's begin with adding applications to the default application as "children" of it:
# For more information about mod_mono:
# http://www.mono-project.com/docs/web/mod_mono/
# Instruct Apache to to map the virtual path "/samples" to the physical path of the examples ("/usr/share/asp.net-demos"):
Alias /samples "/usr/share/asp.net-demos"
# Create an ASP .net application in the virtual path "/samples" mapped to the physical path of the examples ("/usr/share/asp.net-demos")
MonoApplications "/samples:/usr/share/asp.net-demos"
# Instruct Apache that everything in the virtual path "/samples" should be handled by mod_mono:
<Location /samples>
SetHandler mono
Require all granted
</Location>
/etc/init.d/apache2 reload
Another way to accomplish adding a new application is the following:
<web-application>
<!-- Name of the Web Application (It can be empty): -->
<name>samples</name>
<!-- Virtual Path of the Web Application: -->
<vpath>/samples</vpath>
<!-- Physical Path of the Web Application: -->
<path>/usr/share/asp.net-demos</path>
</web-application>
/etc/init.d/apache2 reload
Now, let's replicate a common IIS behavior by having the default web application (the one that ships with the appliance) on port 80 and the examples on port 1080.
# Instruct Apache to listen to the following port:
Listen 1080
# Specify a virtual host to point to the Web Application:
<VirtualHost *:1080>
ServerAdmin webmaster@example.com
DocumentRoot "/usr/share/asp.net-demos"
MonoApplications default "/:/usr/share/asp.net-demos"
MonoServerPath default /usr/bin/mod-mono-server4
</VirtualHost>
# This part is not required if there is any other enabled site which specifies it:
<Location />
SetHandler mono
Require all granted
</Location>
a2ensite samples.conf
/etc/init.d/apache2 reload
Once you follow these steps, you will be able to navigate to http://<Appliance's IP> and https://<Appliance's IP> and have the default web application included with the appliance launched. If you navigate to http://<Appliance's IP>:1080 (or the port you configured) you will navigate directly to the web application which you configured (if you didn't change any bold value, this would be the asp.net examples web application).
Figuring this out was a headache, and I must admit I didn't get this to work by just modifying /etc/mono-server4/debian.webapp (No, if you follow the instructions above you don't need to modify this file). Another thing to take in account is that in the mod_mono page of the mono project site (http://www.mono-project.com/docs/web/mod_mono/), the team recommends to use reload instead of restart, which is why the command provided in the instructions to restart Apache is reload and not restart.
If you desire to replace the default web application provided in the appliance, you have a few choices:
a2dissite 000-default.conf
A few considerations:
# Grant access to the www-data to the web application's directory
sudo chown -R www-data:www-data /usr/share/asp.net-examples
# Grant access to the "root" directory (the one containing your web application) to everyone so they can read it:
sudo chmod -R 755 /usr/share
I hope that this helps you, please let me know if it does.
Regards!