Hosting Tutorial & Guide

Reliable Website Publish on ASP.NET Web Hosting

updated on Oct 13, 2016
The article introduces a reliable website publishing approach on shared ASP.NET web hosting with the control panel such as DotNetPanel, WebSitePanel or Plesk, which helps you out of downtime in the publishing, and protects the whole publish process in transaction. Meanwhile, with the approach, you can manage website versions systematically, and rollback the website securely at any time.

Typical Problems

Let's first go through 3 typical problems which you may have on publishing a new version of the website onto ASP.NET shared web hosting.
  • different configuration - the configuration of website is different between your local environment and the shared web host, which includes database connection string, file storage path, etc.
  • low performance & downtime - possibly, you may use FTP to upload your website files to override the old version on the shared web host. Usually a website consists of too many files such as images, CSS, JS, HTML or code base files. During the uploading, your website is not stable for clients. Besides, the FTP uploading is not reliable and poor performance for large number of files. Sometimes it fails during the upload, and breaks your website.


In this article, we take WebSitePanel control panel of Host4ASP.NET as an example, and introduce the approach in 6 steps.

1. Create Configuration Files For Shared Web Hosting Environment

Create configuration files for running your website in shared ASP.NET web hosting environment, such as web.config and log4net config, with correct database connection strings, file path, etc. And store the configuration files in a separate folder in right structure, from your website project folders.

As the following screenshot, we create a folder named Common Config with all the configuration files which have different settings between shared web hosting and local environment.
Create Configuration Files

2. Publish Website in Visual Studio

In Visual Studio, right click on the web project file, and click the Publish menu item in the context menu. Name the publishing folder by date which indicates a website release version.
Create Configuration Files

3. Write a Batch File to Build Release Package

As you may notice in the above screenshot, there is a batch file Prepare Release Build.bat, which is used to replace the configuration files from the Visual Studio publish with the files which you created at step one, then build a release package.

The commands in the Prepare Release Build.bat are as following.
# Set up the target release. It shall be the same date as the release folder.
SET TargetRelease=2012-01-28

# Override local configuration files with the ones for shared web host
XCOPY /Y/I "Common Config\Web.config" "%TargetRelease%\"
XCOPY /Y/I "Common Config\Config\*" "%TargetRelease%\Config\"
XCOPY /Y/I "Common Config\Spring\*" "%TargetRelease%\Spring\"

# Set up the WINRAR path for compression.
# WinRAR only provides 30 days trial. 
# You can replace WinRAR with WinZIP, 7Zip, or other free ZIP tools.
SET PATH=%PATH%;%ProgramFiles% (x86)\WinRAR;%ProgramFiles%\WinRAR
WINRAR a -afzip -r -x*\_svn\* -ibck "%TargetRelease%\"

ECHO The build is compressed successfully.

4. Upload Release Package

Execute the batch file, get the release package, and upload it to the shared web hosting via FTP. As you're just uploading a single file, the uploading speed is fully depending on your internet connection speed. It usually only takes seconds for a 10MB compressed file.

You can find the uploaded package in file management of the WebSitePanel control panel. Uncompress the zip file to a folder named by date as it's in your local desktop.
Uncompress Release Package in Shared Web Host

5. Go to Website Management

Go to the website management of the control panel, and pick the website for update.
Website Management

6. Update Website

You only need to update the mapping folder path of the website to the latest version. The update may take 20 seconds to complete after you click the SAVE button.
Update Website


As you see, during the whole publishing process, you don't have any downtime. Meanwhile, you have gotten all the published versions as the reference, or for rollback purpose. The website publish with ASP.NET web hosting can be also systematically and secure. It's better than any other approach, which includes FTP or Visual Studio direct web publish.

In this article, we introduce the approach through Host4ASP.NET WebSitePanel, but you can work well with other web hosts using DotNetPanel, Plesk or other control panels which provide file management and website management features.