Deploying to Mono

From Visual WebGui Wiki

Jump to: navigation, search

Contents

Deploying a Visual WebGui application to Mono using Apache and mod_mono

Overview

In this article we will discuss the general steps required to sucessfully deploy a Visual WebGui application aplication to a few distribution types of Linux/Unix servers running Apache2, Mono and mod_mono.

We will describe the general steps used to successfully install a minimal operating system using each distribution's conventions (package distributions) to obtain a version of Mono / mod_mono that is known to support running Visual WebGui applications inside Apache2, how to configure Apache2 and mod_mono to run a basic application sucessfully for different .NET versions and finally how to deploy a very simple Visual WebGui application that includes a global exception handler that will help you catch the exceptions that are thrown server-side and do not show in the browser.

Mono and Visual WebGui compatibility

Mono is gradually adding support for more .NET features and claims they do support .NET 2.0, .NET3.5 and .NET4.0 in the current stable version.

Using the current stable version of Mono (version 2.10) the tests performed while writing this article show that this is indeed true for Visual WebGui and Visual WebGui application in Visual Studio 2005 (NET2), Visual Studio 2008 (NET3) and Visual Studio 2010 (NET4) can all be deployed and run on this version of Mono.

Installing OS, Apache2, Mono and mod_mono

In this section, you will find operating system specific instructions for installing a basic operating system (Linux / Unix), Apache2, Mono and mod_mono, as well as the necessary add-ons required to sucessfully run a Visual WebGui application on Apache2. You will also find some basic hints on how to install and use a couple of handy utilities that may help novice users gather the information required to sucessfully set up this basic system.

You will choose and create an operating system specific folder to deploy your Visual WebGui application to and configure mod_mono to serve your application off of that folder. When you have completed this basic system installation, you can come back here to the main article for further description of the mod_mono specific settings and finally deploy and run your Visual WebGui test application.

Please note that the operating system specific installation instructions that follow, can by no means be interpreted as recommended installation instructions for each operating system, as they are published here for the purpose only, to get a basic server up and running and being able to use it to run Visual WebGui applications. For the recommended installation steps for each type and version of operating system covered here, make sure you read the documentation and follow the recommendations for each one.

CentOS

FreeBSD

Mono directives - What do they mean

Please note that in the description that follows, names and paths to folders are operating system specific and any such names referenced, should be replaced with the name or path which is valid for your specific operating system. To be more specific, names are chosen from CentOS 6 instructions.

MonoServerPath - Decides what NET version is used

This tells mod_mono what version of NET support should be used and where to look for it. The specific path used can vary between Linux distrubutions and versions.

The configuration above uses "mod-mono-server4" (note the "4") which supports the .NET4 framework. For Visual WebGui, this means it will support Visual Studio 2010 applications.

To support Visual Studio 2005 and 2008 Visual WebGui applications, you need to use "mod-mono-server2". And yes, "2" is used for both Visual Studio 2005 and Visual Studio 2008 applications. The configuration for MonoServerPath to support Visual Studio 2005 or 2008 would be:

MonoServerPath CentVWG /opt/novell/mono/bin/mod-mono-server2

As stated above, MonoServerPath can easily be configured on a per application basis. This means that you can have multiple Visual WebGui applications running in various Visual Studio versions, depending on how you configure your server.

AddType - Telling mod_mono that *.wgx is asp.net content

By viewing the default /etc/httpd/conf.d/mod_mono.conf file, you can see the extensions added by a default mod_mono installation.

To tell mod_mono that you want *.wgx to be handled as an asp.net content, and later to be able to use .wgx as an extension (http://myapp/Form1.wgx) for your Visual WebGui application, you need to add an AddType to mod_mono's configuration. As done in this sample, it is added globally (not for a specific VirtualHost).

AddHandler - Telling mod_mono that *.wgx should also be handled by the VirtualHost

The AddHandler is (here) used inside of a VirtualHost, telling mod_mono that it should be considered valid for this VirtualHost. The above AddType tells mod_mono how to interpret or handle it (as an asp.net content).

SetHandler - Telling mod_mono that this application is ASP.NET application

As used in this configuration, the setting is for the whole VirtualHost, meaning that all applications on this VirtualHost will use mod_mono handler.

Location /mono - mod_mono administrative interface

This is just a setting from the mod_mono documentation allowing you to access a simple administrative interface to the mod_mono module via http://yourhost/mono. Please refer to mod_mono documentation for further info.

Sample application and deployment

The sample application used for this test is a very basic and simple application with just one Button that will show a MessageBox, just to show the deployment works. Inside the application, there is a global exception handler implemented that will log unhandled exceptions to the App_Data folder of your application. Catching those exceptions can provide vital information on any problem that may arise, exceptions that do not make it all the way to the browser. There is also an error.aspx simple page that the browser will redirected to in case there are any errors, but as some of the exceptions are thrown on a diffferent thread than the UI thread, the information does not get all the way to the user in all cases.

For the same reason, the web.config of the sample application has been modified slightly to show extended error information to remote user whenever possible.

Please also note that in the description that follows, names and paths to folders are operating system specific and any such names referenced, should be replaced with the name or path which is valid for your specific operating system. To be more specific, names are chosen from CentOS 6 instructions.

Creating a new Visual WebGui application - watch out for single quotes in web.config

Currently, the default Visual WebGui application templates add a single quote around the assemblyname of your application, when registering the default Form1 in web.config.

Some mod_mono framework versions can not handle these single quotes, so they should be removed.

To do this, edit your web.config manually, go to the <Applications> section and see if there are single quotes around your assembly. If they are, remove them.

Testing mod_mono, it seems that Visual Studio 2010 application absolutely need the single quotes removed, while Visual Studio 2005 and 2008 don't mind.

Special web.config requirements for specific operating systems

Please make sure you view information about any specific requirements each operating system makes for your web.config file. These requirements, if any, are documented within the article on Mono installation for each specific operating system, which you can find in the Installing OS, Apache2, Mono and mod_mono section above.

Deploying a basic application

Deploying to mod_mono is a very similar process as Deploying to IIS. Simply copy the bin folder and web.config to /var/www/vwg folder and that's it. Note that both web.config and the bin folder should be directly on the virtual folder, meaning that you will have a /var/www/vwg/web.config file and you will have a /var/www.vwg/bin folder after the deployment.

Deploying additional items for the sample application

The sample application used here, requires that you also copy the error.aspx, global.asax and App_Data to the /var/www/vwg folder. Remember that you need to "chmod 777" on the App_Data folder so the application can write the error information to that folder in case there is an exception to report.

Downloading the sample application

The sample application can be downloaded for Visual Studio versions as follows:

See also

Other references


Personal tools