How to publish a web application using WebMatrix

This walkthrough shows you how to publish your website using WebMatrix.

What you'll learn

  • How to find a hosting provider.

  • How to enter or import your publishing settings from your hosting provider.

  • How to configure WebMatrix for publishing with Web Deploy or FTP.

  • How to check your web application's compatibility with your hosting provider's environment.

  • How to preview files to be published, and see a log of what was published.

What you'll need

To run the steps in this procedure you must be running Windows XP SP3 or a later version of Windows. You'll also need to have WebMatrix installed. For information about how to install WebMatrix, see Microsoft Web Platform Installer.


After you create a website, you typically publish the site to a web hosting provider where others can use it. Publishing a website involves the following tasks:

  • Setting up an account with a web hosting provider.

  • Configuring WebMatrix for publishing. This includes entering settings for your web hosting account and deciding how to publish the database (if your site has one).

  • Clicking the Publish button. WebMatrix shows you the changes it plans to make on the remote server, you approve the changes, and then it publishes the site.

WebMatrix publishes the website by copying files to a remote server, and it can optionally deploy one or more databases to the hosting site.

Hosting Providers

When you publish your website, you copy files from your computer to a web server that's maintained by a hosting company. There are dozens of hosting companies, each offering hosting plans that have different features and pricing.

WebMatrix lets you select a hosting provider right in the tool. These hosting providers all support the Web Deploy process that automates most of the publishing process. However, you don't have to use one of these hosting companies. If you select a different company, you can still publish from within WebMatrix, but you might need to transfer files using FTP, which is a slightly more manual process. FTP also lets you publish Microsoft SQL Server Compact 4.0 databases, but not databases that use SQL Server or SQL Server Express.

Among the publishing options is SSL, which stands for secure sockets layer. (SSL is what you're using if you access a Web site using https:// instead of http://.) SSL encrypts the information going between the browser and server, and is a good idea for pages that involve private information like passwords and credit-card numbers. Setting up SSL requires extra steps like purchasing and configuring a certificate that's used for encryption. We don't cover those steps here, so we also won't provide any information about how to configure SSL during publishing.


If you're using SQL Server Compact as your database, the data is stored in an .sdf file. When you publish the database, WebMatrix copies not only the .sdf file but also the database program itself to the web server. This ensures that the published site will work even if SQL Server Compact isn't already installed on the web server.

If you're using a SQL Server or MySQL database, WebMatrix publishes the database by creating scripts that run in a database that has been created for you by your hosting provider. These scripts create database tables and insert data into them in order to replicate the structure and data that you have in the database on your computer.

If you're using a SQL Server Compact database and want to publish to a SQL Server database, you must migrate the data to SQL Server before publishing. For instructions, see Migrate a database to SQL Server. You might want to do this to take advantage of SQL Server features such as stored procedures and its additional capabilities, such as handling more than 256 concurrent connections or creating databases larger than 4 gigabytes.

Setting Up a Web Hosting Account

To set up web hosting, you must find a web hosting provider and set up an account.

  1. In the Home tab, click the arrow below Publish, and then click Find Web Hosting.


    The Find Web Hosting web page lists hosting providers.


  2. Select one of the hosting providers and click Learn More.

  3. Follow the directions provided by the hosting provider's site to set up a new account.

    Support for a SQL Server database might be an option that costs extra. If you plan to publish a SQL Server Compact database (.sdf file), you don't need this option.

After your account is set up, the hosting provider typically sends you an email message that contains information you'll need in order to publish your website. The values might look like this:

  • Server:

  • User Name: user123

  • Password: password

  • Site Name:

  • Destination URL:

If your hosting account includes a SQL Server database, you'll also get information that you will need to publish your database, which will typically look like this:

Your database connection string is: Password=password;User ID=username;Initial Catalog=username.hostingcompany;Data

Some hosting providers will send you a .PublishSettings file which will contain these settings for you. When you configure WebMatrix for publishing, you can use the Import Profile feature to import these settings from the .PublishSettings file so that you will not have to type them in by hand.

Configuring WebMatrix for Publishing

  1. Open the website in WebMatrix.

  2. In the Home tab, click Publish.


    The Publishing Settings dialog box is displayed. (You can also get to this box by clicking the arrow below Publish, and then by clicking Settings.)


  3. If you have the .PublishSettings file from your hosting provider, click Import publish settings to import the settings. If you selected a hosting provider through WebMatrix, you can use Web Deploy for the Protocol setting. If you're using a hosting provider that doesn't support Web Deploy, or if you want to publish using FTP instead of Web Deploy, change the Protocol setting to FTP.

  4. If you don't have a .PublishSettings file, follow the steps below to enter your publishing settings by hand. Otherwise, you can skip the next step.

  5. If you are using Web Deploy, enter the information you received from the hosting provider in the text boxes:

    Option What to enter


    Enter the "Service URL" or "Server Name" provided by the hosting company, like this:

    If the service URL includes the prefix https:// and the suffix :8172/msdeploy.axd, you can leave out the prefix and suffix.

    User Name/Password

    Enter the credentials that the hosting provider provided for your account. (If you also signed up for a database for your account, the database might have a different username and password, so be sure that you use the right ones).

    Site Name

    Enter the "Site" or "Site/Application" value from the hosting company, like this: 

    Destination URL

    Enter the URL that people will use to browse your site over the internet, like this:


  6. If you want to use FTP instead of Web Deploy, select FTP. Some of the fields are different:


  7. If you are using FTP:

    1. Enter the Server, User name, Password, and Destination URL as described above for Web Deploy.

    2. In the Site path box, enter the value identified by the hosting company as the "Site Root," such as /wwwroot. This field is optional.

  8. If you want to upload only the files that have changed locally when you use FTP, click Cancel. Then, click the tab in the upper left corner of WebMatrix and select Options.


    On the Publishing tab, check Make FTP faster by only publishing the files that have changed on this computer.


    Click Save and then return to publish settings.

  9. If you don't want to enter the password every time you publish, select the Save password check box.


  10. Click Validate Connection to verify that WebMatrix is able to connect to the hosting provider. WebMatrix displays the results to the right of the button.


    If the connection test fails, double-check that that you entered the information correctly. If you did but validation continues to display an error, see the hosting provider's resources for help.

  11. If your website uses a full SQL Server or SQL Server Express database (that is, not a SQL Server Compact database), click the box next to your database to enter the connection string and other information that was sent to you by the hosting provider.


    If the database doesn’t appear in the dialog box, make sure it has a connection string in the Web.config file. For more information, see About Connection Strings later in this document. If a SQL Server Compact database does not appear in this dialog box, make sure that the .sdf file is in the App_Data folder.

  12. Click Save to save your publishing settings.



You are now starting the publishing process. Before WebMatrix makes any changes at the hosting company's web server, it tells you what it plans to do. You can then review the plan and modify it if necessary. Then when you're ready, you tell WebMatrix to go ahead and publish.

  1. The Publish Compatibility dialog box appears.


    WebMatrix checks for dependencies the first time it publishes and will let you know if there is a problem. (You can also use this feature separately in WebMatrix by clicking Publish in the ribbon, and then clicking Check Compatibility.) You do not need to perform this step every time you publish. However, if you have a site that has many dependencies and takes a long time to publish, you may want to use the check compatibility feature more often. 

    Click Yes.

  2. The results appear in the Publish Compatibility dialog box. If the results are OK, click Continue.


  3. The Publish Preview dialog box appears.


  4. Review the list of files and databases and make changes if necessary. For example, you might want to clear check boxes under Changed Files to exclude some files.

    Important: If you're publishing a database and the database already exists in the hosting provider's site, whatever is in that database will be overwritten.

  5. Click Continue. WebMatrix publishes the website, showing status messages in the navigation bar at the bottom of the screen. The publishing process is done in the background, which means you can continue to work in WebMatrix while it is publishing.

  6. In the notification bar at the bottom of the screen, you can click Log to see a detailed log of the publishing activity.



  7. If you see something in the log that catches your attention during the publishing process, you can click Pause Scroll to go back and examine what you saw more carefully.

  8. When the publishing process is complete, the notification bar lets you know:


    To verify that publishing was successful, browse to the site. If you published a database, make sure you try any pages that display data from the database.

Note:   If your site has a Web.config file, the copy on the hosting provider's web server might look slightly different. For example, if you published a SQL Server database, it will have the hosting provider's connection string value so that the published site will use the database at the hosting provider.

About Connection Strings

If you're using a SQL Server (not SQL Server Compact) database, your site has to have a Web.config file with a connection string that tells the site how to connect to the database. To set up publishing, you enter the connection string for the destination database in the Publishing Settings dialog box. When you publish to a hosting company, the company provides you this string. If you want to publish to another server on your own network, you have to create the string yourself. (And in that case you also have to know the site and application name as they appear in IIS Manager, and enter this as the Site Name in the Publishing Settings dialog box.)

The following example shows a connection string in a Web.config file for a SQL Server Express database named CohoWinery.mdf. The .mdf file is located in the App_Data folder.

        <add name="CohoWineryConnectionString" 
          connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CohoWinery.mdf;Integrated 

Security=True;User Instance=True" providerName="System.Data.SqlClient" />

The following example shows a connection string for a full SQL Server database named CohoWinery that is on a server named "Server01", using integrated Windows authentication. The connection string for the database named SmallBakery shows how to use SQL Server authentication (that is, how to specify a user name and password).

        <add name="CohoWineryConnectionString" 
          connectionString="Data Source=Server01;Initial Catalog=CohoWinery; Trusted_Connection=True" />
        <add name="SmallBakeryConnectionString" 
          connectionString="Data Source=Server01;Initial Catalog=SmallBakery; User Id=username; 

Password=password" />

More Information

For information about how to download, edit, and republish your site after you have published it, see Download, Edit, and Republish Your Website with WebMatrix.

You can discuss this article using the adjacent Facebook talkback.

For technical questions please visit our discussion forums, where we have a vibrant community of developers like you, as well as Microsoft engineers who are ready to answer your questions!