About this post

This post gives you step by step instructions for how to deploy an ASP.NET website. In the video I'm using an Umbraco site as an example, but it applies to any ASP.NET website. If you are unsure of any of the steps then watch the video.

Watch the video

Create configurations and transforms

  • Create different configurations
  • Create config transforms for UAT and LIVE
  • Delete Debug and Release
  • Make sure all of the required files are included in the build

Publish the web project

  • Right click on the web project, and choose Publish
  • Select a publish target, choose Custom
  • Enter a profile name. You want one for each configuration. I'll start with UAT
  • In publish method, choose File System
  • In the target location, choose a relevant folder, if it doesn't exist it will create it for you.
  • Click next
  • Choose the configuration, so I will choose UAT
  • File publish options, tick Delete all existing files prior to publish
  • Click next
  • Look at the path where it will be published to, make sure it is correct.
  • Click on Publish
  • Look at the output, make sure it builds correctly and outputs the files to the destination location.
  • Now go to the folder where the files are, add them all to a zip file, with a name such as ProjectName YYYY-MM-DD.zip
  • Saving the file in this format means even if they are sorted alphabetically they will be in the correct date order.

Put the files onto the server

  • Log onto your server using Remote Desktop (RDP)
  • If you don't have a server, you could practice doing this on your computer.
  • On the server, navigate to the web root folder, normally called wwwroot, could be in C:\inetpub
  • Create a folder for the web project
  • Paste the zip file inside this folder
  • Right click, extract all
  • Delete the zip file

Sort out folder permissions

  • Make sure the following users have permission to modify this folder: IUSR, IIS_IUSRS

Backup the local database

  • Open SQL Server Management Studio
  • Connect
  • Open out the databases tree view on the left
  • Right click on the database for your project
  • Choose tasks and backup
  • In the destination section, choose disk
  • Remove any that are already in the list below and click on add
  • Choose a destination folder and put the name of the file in, something like ProjectName-DB-YYYY-MM-DD.bak, click on OK
  • Click on OK in the main window.

Create a database on the server

  • Go to the destination folder where the backup is saved.
  • Right click on it and add it to a zip file
  • On the server, paste the db zip file somewhere.
  • Right click, extract all
  • Open SQL Server Management studio
  • Connect to the server
  • If you don't have a database already, right click on databases and choose New Database.
  • Name it after your project, I like to add .UAT or .LIVE after the name.
  • In options make sure the SQL version is the same as the database on your local machine.

Restore the database using the backup

  • Right click, tasks, restore
  • In device, choose the backup file ending .bak
  • In the dropdown, choose the database from the backup.
  • In the destination dropdown choose the new or existing database on the server for the project
  • Go to the files page, choose the relevant mdf and log files
  • In options, make sure overwrite the existing database is ticked.
  • Click on OK

Sort out database permissions

  • Under security, go to users and create a new login.
  • Username, password etc SQL only
  • In User mappings tick this database, reader, writer owner.

Setup a site in IIS

  • Create a site in IIS
  • Point the site the dated folder you created
  • Add the website url as the binding, e.g. mine is uat.fionawhitfield.com

Start the site

  • Eliminate any errors
  • Make sure the connection string is correct

Need somewhere to host your site?

If you have a site and you want to find somewhere to host it, I recommend eUKHost. I use them myself, they are a great hosting provider.

Want to thank me?

If I've helped you out and you want to thank me, why not buy me a coffee?

Paul Seal

A .NET Web Developer from Derby (UK) who specialises in building Content Management System (CMS) websites using MVC with Umbraco as a framework. Paul is passionate about web development and programming as a whole. Apart from when he's with his wife and son, if he's not writing code, he's thinking about it or listening to a podcast about it.

Web: codeshare.co.uk

Comments

Share Top