Precompiling your Visual Web Developer Asp.net Projects

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

 

Precompiling Asp.net Web Projects
Visual Web Developer – Microsoft’s free version of Visual Studio, is a great tool to create quality Asp.net 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 Asp.net server is when the Asp.net 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 DoTheWeb.net Asp.net Precompiling tool!
You can use this handy GUI to precompile your websites.  DoTheWeb.net Asp.net Precompiler

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

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 Asp.net 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:
http://dev.mysql.com/downloads/connector/net/5.2.html

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 Asp.net to use for web apps

Asp.net 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 Asp.net

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:

CREATE DATABASE testsite;

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 127.0.0.1 (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 = 127.0.0.1
            
            change to :
            
            #bind-address = 127.0.0.1

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