Precompiling your Visual Web Developer Projects

For more information about LAMA servers, checkout:
LAMA – Best of ALL worlds tutorial


Precompiling Web Projects
Visual Web Developer – Microsoft’s free version of Visual Studio, is a great tool to create quality Sites.  VWD being free- does not include all the tools that Visual Studio does. In this case VWD does not include the option to precompile your web project.

Why Precompile?
Well – there are a couple reasons.  First, to remove all code in your project and place it in compiled DLL’s.

This may be a good option for those who host on a shared server.  That way your code is not placed in plain text on the server for others to see.

Next, to save server resources.  The first hit on the server is when the project is compiled.  If you precompile, then it saves those resources by not having to compile on the server.

Lastly, Mono’s vb compiler for Linux is a few steps behind the C# compiler.
If you have a LAMA server,  and like to use VB as your language.  You can precompile your site to ensure that it will work correctly.

Use The Precompiling tool!
You can use this handy GUI to precompile your websites. Precompiler

NOTE: This is a ClickOnce Program, you may have to use Internet Explorer or Firefox to open it from the website.

A MySql Test site to for your LAMA Server

This is part of the LAMA – Best of all worlds tutorial
LAMA Tutorial Home Page


MySql Test Site with Visual Web Developer 2005

1.) Lets open up VWD, and create a new website called mysql-test-site

2.) Add the Mysql Connector/Net to the references.
Right click on the website name in Solution explorer, and choose Add Reference.

Select the MySql.Data from the list, and choose OK.

3.) Add a Data Grid View to the page.
In the Toolbox under Data, Select Grid View and drag it out onto the blank page.

4.) Your Code behind file should have the following code in it:

Imports System.Data

Imports MySql.Data.MySqlClient

Partial Class _Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As ObjectByValAs System.EventArgs) HandlesMe.Load

‘The MySql Connection String:  replace IP address with the IP address of your LAMA server

Dim Conn As NewMySqlConnection(“server=,database=testsite,Uid=aspnet,Pwd=aspnetpassword”)

Dim sSql As String = _

“Select * from phonebook”

Dim DA As New MySqlDataAdapter(sSql, Conn)

Dim DT As New DataTable


Me.GridView1.DataSource = DT ‘set the datagrid to the datatable


End Sub

End Class


5.) Run the project in VWD to make sure it works.  You should see a datagrid with our test data in it.

If you see John Doe, then its time to copy your project into your asp_net share and setup a test site for it.

Follow the instructions in the tutorial for copying and setting up the site. users: Make sure to precompile your sites before copying them to the LAMA server.

Tutorial – Configure Apache for Site

Precompiling your Visual Web Developer Sites

Configuring MySql for your LAMA server and Visual Web Developer


This is part of the LAMA – Best of all worlds tutorial
LAMA Tutorial Home Page

MySql Connector .Net

MySql Connector/Net is the component that allows to talk to Mysql Databases.

You will need this connector to be installed on the machine that has Visual Web Developer installed.
The latest version of MySql Connector is 5.2. 

Download the Widows Binary (ZIP) file from MySql Website:

1.)Unzip and go thru the Installer.  When it is completed, we will have to add the Assembly file to the LAMA Server.

2.)Navigate to the MySql Connector/Net folder inside Program Files.  This is usually:

C:\Program Files\MySQL\MySQL Connector Net 5.2.1

3.)Navigate into the Binaries\.NET 2.0\ folder.

You should see a MySql.Data.dll file.

4.)Copy that file into your asp_net share on your LAMA server.

5.)Now use Putty to connect to your LAMA server.

6.)Change to the asp_net directory

cd /asp_net

7.) Run the gacutil to install the MySql Assembly into Mono’s Global Assembly Cache

sudo gacutil -i MySql.Data.dll

You should see:

Installed MySql.Data.dll into the gac (/usr/local/lib/mono/gac)


Setting up a MySql user for to use for web apps needs to have access to the MySql database for it’s web apps.  To allow this, we are going to setup a new user on the LAMA server.

1.) Use  Putty to connect to your LAMA server.

2.)Go into MySql.  You will need to know the root password if you set one during install.

sudo mysql -u root -p

It will ask for password, hit enter if you didnt use one

3.) From the Mysql command line, add a user for

CREATE USER ‘aspnet’ IDENTIFIED by ‘aspnetpassword’;

This creates an aspnet user with a password of aspnetpassword
*This is for testing / demonstration purposes only.  For securing your mysql database please see MySql’s website for more information.

4.) Now we need to grant privileges to the user

GRANT ALL ON *.* TO ‘aspnet’@’%’ IDENTIFIED BY  ‘aspnetpassword’;

This grants all privileges to the aspnet user
*This is for testing / demonstration purposes only.  For securing your mysql database please see MySql’s website for more information.


Create a sample database

We will setup a simple database for testing.  We will make a simple phone book.

1.) Create the database,  from the Mysql command line type:


2.) Change to the testsite database

USE testsite;

3.) Create the phonebook table

CREATE TABLE `testsite`.`phonebook` ( `name` VARCHAR(50) NOT NULL, `number` VARCHAR(45) NOT NULL );

This will create a table (phonebook) with 2 fields: name, number

4.) Add a test record

INSERT INTO phonebook VALUES (‘John Doe’, ‘555-123-45678’);


One more thing about MySql:

By default MySql does not allow connections from outside computers.  They only allow connections from (localhost).

If you want to test your connections to MySql on your LAMA server from your development machine, you will have to make a change to your MySql configuration file.

To do this:

1.) Use  Putty to connect to your LAMA server.

2.) change directory to the Mysql configuration directory.

cd /etc/mysql

3.) Make a copy of your my.cnf file

sudo cp my.cnf old_my.cnf

4.) Open my.conf in your editor

sudo pico my.cnf

5.) find the following line and comment it out:

            bind-address =
            change to :
            #bind-address =

6.) ctrl-x to exit, Y to save the file

7.) restart MySql

sudo /etc/init.d/mysql restart

Security note: This opens up your MySql server to anyone.  Please take all necessary precautions before making your LAMA server live on the internet. You can learn more about MySql security from the MySql web site.

Next in tutorial .. Create a MySql test site

Configuring Apache on your Ubuntu LAMA Server for websites


This is part of the LAMA – Best of all worlds tutorial
LAMA Tutorial Home Page

Apache Web Server

During your install of Ubuntu 8.04 server, one of the install options was LAMP Server.  This installs Apache, Mysql and PHP. 

To setup Apache, we will adding a file to the apache sites-available directory on the LAMA server.

To get started:
Use Putty to connect to your LAMA server.

1.) Change to the Apache sites-avaliable config directory

cd /etc/apache2/sites-available

2.) Add a file for your site

sudo pico testsite

3.)Pico will open a blank file.  Add the following to create a configuration entry for your site.

    Listen 81
    NameVirtualHost *:81
    <VirtualHost *:81>
    DocumentRoot /asp_net/testsite


This is a simple config, for more extensive configuration options, please see Apache’s Web site.

Apache will listen for requests on port 81, and will look in your asp_net folder.

4.) Now tell apache to load that site into its config.

sudo a2ensite testsite

This makes a link to this file, and puts it into the sites-enabled directory.

5.)Reload Apache

sudo /etc/init.d/apache2 force-reload


Testing it out:

Now from your browser type:

http://{your LAMA server IP address}:81


You should see your site in Apache!


Next .. Getting your Asp.Net Mysql Setup

Using Microsoft’s Free Visual Web Developer to create LAMA ready sites


This is part of the LAMA – Best of all worlds tutorial
LAMA Tutorial Home Page

Microsoft Visual Web Developer 2005

Visual Web Developer is a free version of Visual Studio, that just does web projects.  For this tutorial we will be using VWD 2005, because it is .net 2.0 based, and Mono’s 2.0 base is very extensive – so most projects will work ‘out of the box’.

Using VWD along with your LAMA server is a great way to create and host websites for free!

Download from Microsoft’s Website.

Create a sample Asp.Net Project

Partial Class _Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As ObjectByValAs System.EventArgs) HandlesMe.Load

Response.Write(“My LAMA Server is Working!”)

End Sub

End Class

3.) Run the project in VWD.  You should see My LAMA Server is Working!

C# or & Precompiling the Project

It seems that Mono has extensive support for C#.  So anything you write in C# should compile and run right in Mono.

VB is a different story.  It seems that the VB compiler for Mono is a bit behing the C# counterpart.  There is a way around this though, By pre-compiling your site.

Visual Web Developer does not include a precompilation tool for it’s web sites, but you can use the Precompilation tool. 
This tool is a simple GUI interface for the .net precompilation command line utility.

Note for users!!
You must precompile your website project for it to work successfully in your LAMA server. 

Click here to run the Precompiler



Copy your website into your LAMA shared folder

Once you have a simple project ready.  Copy it into the asp_net share on your LAMA server.

If you used the precompiler,  you can enter your LAMA server as the destintion path, and your compiled project will be copied right into your LAMA server.

1.) Open your network places and type: \\{your LAMA IP address}
You should see the asp_net folder

2.) Copy your project folder (\testsite) over to the asp_net folder

Now we will have to setup Apache on our LAMA server to see our site.

Next .. Configure Apache for Site