Getting Ready to Publish

Before you publish your site to the world-wide-web it is a good idea click on the ‘Reports’ tab and ask WebMatrix to run a full site report. The generated report includes useful information on the site’s performance and hints on Search Engine Optimisation (SEO), to help make your site more visible to popular search engines such as Yahoo, Google and Bing.



To correct any errors or warnings simply click the ‘Edit this page’ link to be taken directly to the area of concern.




At this point it is also worth proof-reading your content and using the ‘Run’button on the toolbar to carry out cross-browser compatibility checks to ensure an optimal experience for all your users.


Once you are satisfied that your web site is ready for publication it is time to find a suitable hosting provider.


Finding a Hosting Provider

WebMatrix has a facility designed to help you find a suitable host for your web site. If you already have an account with a web hosting provider you may want to skip to the next section, ‘Configuring WebMatrix Publish Settings’.




By clicking on the ‘Need web hosting for your web site?’ button on the ‘Site’tab of the WebMatrix home page you will be directed to the ‘Find Web Hosting...’ page of the Microsoft web site.



WebMatrix passes some basic information about your web site to this page in order to generate a list of hosting plans tailored to meet the requirements of your site. The results can be filtered and the criteria changed, using the tools on the page.


You should be careful about changing some of these settings, in particular the scripting language; otherwise you could end up purchasing an account on a web server which won’t support the language in which your site has been written. If you are unsure of the scripting language you should leave it set to its default of ASP.NET 4.0. This is the default scripting language for all new WebMatrix projects.


The filters for minimum and maximum price, storage (GB), number of SQL databases, number of e-mail accounts and bandwidth per month can be set using the sliders.


The initial storage required for your site can be estimated by viewing the folder properties of your local site in Windows Explorer. However, this should only be taken as a guide as the overall required storage depends a great deal on the features of your site. For example, if your site has a facility to allow users to upload content, or contains a blog which will grow over time, be sure to allow for future expansion. Generally though web sites primarily consist of text files and small images and do not require a huge amount of disk space.


If your site requires the use of a database other than SQL Server Compact you will need to find a web host which has this facility. If you are using SQL Server or MySQL, WebMatrix will automatically publish scripts to create tables and insert data to replicate the schema and data on your development computer. These scripts will need to be run on the database provided for you by your chosen hosting provider, usually through the host’s control panel.


If you are using a SQL Server Compact database there is no need to choose a host with additional database facilities as SQL Server Compact is file-based, which can deliver a significant cost-saving in some cases. If you do choose this option though it is important to consider the disk-space required to store the database files - SQL Server Compact databases can grow to a maximum of 4GB in size. In addition to the SQL Server Compact (.sdf) file containing the data, WebMatrix will also upload the database program itself to the web server to ensure the site will work even if SQL Server Compact is not already installed.


To set up a new account, choose a suitable provider and click the green ‘Learn More’ button. This will display more information about the hosting package and a link to ‘Sign Up’ on the hosting company’s web site.


Configuring WebMatrix Publish Settings

Once you have chosen and purchased a hosting plan, the provider will typically send you an email confirming the details of your account and the information necessary to configure WebMatrix for publishing. This information will be provided either as a list of settings or as a .PublishSettings file.


Configuration Using A Publish Settings File


If your hosting company has provided you with a .PublishSettings file, this is the easiest way to set up publishing within WebMatrix.



To open the ‘Publish Settings’ dialog click the ‘Set up the remote publishing location for your web site’ button in the ‘Site’ tab of the WebMatrix home page.




Click on the ‘Import Publish Settings’ link and browse to your Publish Settings file. This will populate the Publish Settings dialog for you, including connection strings for any non-SQL Compact databases you may be using.


Click the ‘Validate Connection’ button to have WebMatrix check the settings and click ‘Save’.


Manual Configuration Without A Publish Settings File

If your web hosting company has not provided you with a .PublishSettings file it is easy to configure the Publish Settings manually using the host settings, usually sent to you in your confirmation email or available through the host’s control panel.




If you selected your hosting provider through WebMatrix you can leave the Protocol drop-down set to ‘Web Deploy’. If you did not choose your hosting provider through WebMatrix and your host does not support Web Deploy, you should skip ahead to the next section, ‘Configuring Publish Settings Using FTP’.


Enter the information provided to you by your web host into the boxes provided:


·
Server– This is typically referred to as the ‘Server Name’ or ‘Service URL’.

o E.g.- server.sample.com


·
User Name& Password – These are usually chosen by you at sign up, although alternatives for publishing may be set by the provider.

·
Site Name– Web hosting companies often refer to this as the ‘Site’ or ‘Site/Application’

o E.g.- site.server.sample.com


·
Destination URL – This is the URL that will be used to browse to your site.

o E.g.–
http://site.server.sample.com

Once you have entered all of the required information, click the ‘Validate Connection’ button to verify that WebMatrix can successfully connect to your hosting account and click ‘Save’.


Configuring Database Connections

If your web site is using a database other than SQL Server Compact, your site will need a web.configfile that tells the site how to connect to the database on your local development machine. When you add a database through the ‘Connect to Database’dialog in the ‘Databases’ tab, the file is automatically created and configured for you and looks something like this:


01.<?xml version="1.0" encoding="UTF-8"?>
02.
03.<configuration>
04.
05. <connectionStrings>
06.
07. <add connectionString="Uid=testUser;Server=testDBServer; Pwd=passw0rd; Database=testDB" name="testDB" providerName="System.Data.SqlClient" />
08.
09. </connectionStrings>
10.
11.</configuration>


Your web host will provide you with a connection string, or a series of settings, for connecting to the hosted database which you should enter in the‘Publish Settings’ dialog box.



These settings tell WebMatrix how to connect to the live data and overwrite the web.config settings on the host server.

Publishing Your Site to the World Wide Web

OK, so you have checked your site for errors, selected a web host and configured the WebMatrix Publish Settings; it’s time to publish your site.

The first time you click the ‘Publish’ button on the WebMatrix toolbar, a dialog will appear asking whether you would like WebMatrix to test your sites compatibility and adjust .NET settings on the remote server if necessary. Click ‘Yes’ to proceed with the test:



Once the test is complete the ‘Publish Preview’ dialog will be displayed. This dialog allows you to check the list of files to be published and make changes as necessary.


If this is the first time you have published your site you should ensure that you check the boxes next to any necessary databases, to have MebMatrix include them in the file upload. On subsequent publishes only the changed files will appear in this dialog, enabling you to easily keep your local development and remote hosted sites synchronized.




Once you are happy with your selection, click ‘Continue’ to publish your web site.


The yellow bar at the bottom of the screen will show the progress of file uploads and let you know when the publishing has been completed:




And that’s it! You have seen how easy it really is to find a suitable web site host and deploy feature-rich, dynamic, data-driven websites to your web server, using the power and flexibility of Microsoft WebMatrix.