Deploying an ASP.NET Web Application to a Hosting Provider Using Visual Studio Tom Dykstra
Total Page:16
File Type:pdf, Size:1020Kb
Deploying an ASP.NET Web Application to a Hosting Provider using Visual Studio Tom Dykstra Summary: This series of tutorials shows you how to make an ASP.NET web application available over the internet by deploying it to a third-party hosting provider. The deployment method used is Visual Studio one-click publish. The tutorials illustrate deployment first to IIS on the development computer for testing. They then show you how to deploy to the hosting provider as the production environment. Category: Step-By-Step Applies to: ASP.NET 4.0 and earlier, Visual Studio 2010 Source: ASP.NET site (link to source content) E-book publication date: May 2012 162 pages Copyright © 2012 by Microsoft Corporation All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is intended or should be inferred. This book expresses the author’s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Deployment to a Hosting Provider Contents Deployment to a Hosting Provider: Introduction - 1 of 12 ........................................................................ 6 Overview ............................................................................................................................................ 6 Intended Audience ......................................................................................................................... 6 The Hosting Provider Shown in the Tutorials .............................................................................. 6 Web Application Projects versus Web Site Projects..................................................................... 7 ASP.NET Web Forms versus ASP.NET MVC ............................................................................. 7 Programming Language ................................................................................................................ 7 Troubleshooting During this Tutorial ........................................................................................... 7 Comments Welcome ...................................................................................................................... 7 Prerequisites ...................................................................................................................................... 7 Downloading the Sample Application ............................................................................................... 8 Reviewing Application Features that Affect Deployment ................................................................ 9 Deploying SQL Server Compact Databases - 2 of 12 ............................................................................... 11 Overview .......................................................................................................................................... 11 SQL Server Compact versus SQL Server Express ......................................................................... 11 Configuring the SQL Server Compact Database Engine for Deployment..................................... 12 Creating an Application Database for Deployment ........................................................................ 14 Creating a Membership Database for Deployment ........................................................................ 18 Renaming the Production Databases .............................................................................................. 22 Setting Connection Strings so that Only Development Databases are Used in Development ....... 23 More Information ............................................................................................................................ 25 Web.Config File Transformations - 3 of 12 ............................................................................................. 26 Overview .......................................................................................................................................... 26 Web.config Transformations versus Web Deploy Parameters ...................................................... 26 Creating a New Build Configuration .............................................................................................. 26 Preventing Entity Framework Code First from Dropping the Production Database ................... 29 Limiting Error Log Access to Administrators ................................................................................ 30 1 Setting an Environment Indicator .................................................................................................. 32 Disabling Debug Mode .................................................................................................................... 33 Setting Connection Strings .............................................................................................................. 33 More Information ............................................................................................................................ 34 Configuring Project Properties - 4 of 12 ................................................................................................. 35 Overview .......................................................................................................................................... 35 Configuring Deployment Settings in the Project Properties Window............................................ 35 Making Sure that the Elmah Folder gets Deployed ........................................................................ 39 Deploying to IIS as a Test Environment - 5 of 12 .................................................................................... 40 Overview .......................................................................................................................................... 40 Configuring the Application to Run in Medium Trust ................................................................... 40 Installing IIS and Web Deploy ........................................................................................................ 41 Setting the Default Application Pool to .NET 4 .............................................................................. 41 Publishing to IIS .............................................................................................................................. 45 Testing in the Test Environment ..................................................................................................... 49 More Information ............................................................................................................................ 53 Setting Folder Permissions - 6 of 12 ....................................................................................................... 55 Overview .......................................................................................................................................... 55 Testing Error Logging and Reporting ............................................................................................ 55 Setting Write Permission on the Elmah Folder .............................................................................. 56 Retesting Error Logging and Reporting ......................................................................................... 58 More Information ............................................................................................................................ 59 Deploying to the Production Environment - 7 of 12 ............................................................................... 60 Overview .......................................................................................................................................... 60 Selecting a Hosting Provider ........................................................................................................... 60 Creating an Account ........................................................................................................................ 60 Setting the .NET Framework Version............................................................................................. 63 Publishing to the Hosting Provider ................................................................................................. 66 Setting Folder Permissions for Elmah ............................................................................................ 68 Testing in the Production Environment .......................................................................................... 71 Creating a More Reliable Test Environment .................................................................................. 75 Preventing Public Access to the Test Site ...................................................................................