assumes apache2 installed via apt-get
apt-get install mono-apache-server2
apt-get install libapache2-mod-mono
a2enmod mod_mono
/etc/init.d/apache2 restart
edit the virtualhost file or httpd.conf file and add this to the end. In the case of virtualhost, for some reason this must reside outside of the tags.
MonoPath default "/usr/lib/mono/2.0" MonoServerPath default /usr/bin/mod-mono-server2 AddMonoApplications default "/:/var/www" <location> MonoSetServerAlias default SetHandler mono </location>
create a file called NumberService.asmx and place the following code:
<%@ WebService Language="C#" Class="MathService.MathService" %> using System; using System.Web.Services; namespace MathService { [WebService (Namespace = "http://mono.local/NumberService")] public class MathService : WebService { [WebMethod] public int AddNumbers (int number1, int number2) { return number1 + number2; } [WebMethod] public int SubtractNumbers (int number1, int number2) { return number1 - number2; } } }
Leave a Reply