ASP.NET Web Deployment using Visual Studio









.NET Tutorial for Beginners

programming model (similar to Visual Basic 6 that simplify development of web NET framework samples and quick start tutorials require a Microsoft SQL ...
dotNET Tutorial for Beginners


1. Introduction 2. .NET Basics 3. C# Basics 4. Code Elements 5

C# is a general purpose object oriented programming language developed by Microsoft for program development in the .NET. Framework. It's supported by .NET's 
csharp dotnet adnanreza


Preview ASP.NET Tutorial (PDF Version)

NET programming language. As we are going to develop web-based applications using ASP.NET web application framework it will be good if you have an.
asp.net tutorial


VB.NET

NET Framework and the common language runtime with the productivity benefits that are the hallmark of Visual Basic. This tutorial will teach you basic VB.
vb.net tutorial





Untitled

NET initiative led by Anders Hejlsberg. This tutorial covers basic C# programming and various advanced concepts related to C# programming language. Audience.
csharp tutorial


.NET Framework Essentials 2nd Edition

NET Framework it targets seasoned developers with experience in building Windows applications with Visual. Studio 6 and the Visual Basic and Visual C++ 
Net Framework Essentials Edt


Créez votre site web avec ASP.NET

12 août 2019 ASP.NET : le framework web de Microsoft ... ASP.NET est une puissante technologie regroupant des fonctionnalités multiples qui va nous.
creez votre site web avec asp net


.NET Framework

You can share this PDF with anyone you feel could benefit from it downloaded the NET Framework est un ensemble de bibliothèques et un environnement ...
dot net framework fr





ASP.NET Web Deployment using Visual Studio

Summary: This tutorial series shows you how to deploy (publish) an ASP. The .zip file contains multiple versions of the project and a PDF file that ...
aspnet web deployment using visual studio


Wpf Tutorial [PDF] - m.central.edu

applications using C# and XAML for design. This book will get you through not only the basics but also some of the more advanced concepts of WPF in .NET 5.


211684 ASP.NET Web Deployment using Visual Studio

ASP.NET Web Deployment using

Visual Studio

Tom Dykstra

Summary: This tutorial series shows you how to deploy (publish) an ASP.NET web application to a Windows Azure Web Site or a third-party hosting provider, by using Visual Studio 2012 or Visual Studio 2010. You develop a web application in order to make it available to people over the Internet. But web programming tutorials typically stop right after they've shown you how to get something working on your development computer. This tutorial begins where the others leave off: you've built a web site, tested it, and it's ready to go. What's next? This tutorial shows you how to deploy first to IIS on your local development computer for testing, and then to Windows Azure or a third- party hosting provider for staging and production. The sample application that you'll deploy is a web application project that uses the Entity Framework, SQL Server, and the ASP.NET membership system. The sample application uses ASP.NET Web Forms, but the procedures shown apply also to ASP.NET MVC and Web API.

Category: Step-by-Step

Applies to: ASP.NET, Visual Studio 2010, Visual Studio 2012, Windows Azure Source: ASP.NET Site (http://asp.net/web-forms/tutorials/deployment/visual-studio- web-deployment/introduction)

E-book publication date: April, 2013

Copyright © 2013 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.

7KLVERRNH[SUHVVHVWKHDXWKRU·VYLHZVDQGRSLQLRQV7KHLQIRUPDWLRQFRQWDLQHGLQWKLVERRNLVSURYLGHGwithout 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.

1

ASP.NET Web Deployment using Visual

Studio

Contents

Introduction .................................................................................................................................................. 6

Overview ................................................................................................................................................... 6

Intended audience .................................................................................................................................... 6

Using a third-party hosting provider ......................................................................................................... 7

Deploying web site projects ...................................................................................................................... 7

Deploying ASP.NET MVC projects ............................................................................................................. 7

Programming language ............................................................................................................................. 7

Database deployment methods................................................................................................................ 7

Entity Framework Code First Migrations .............................................................................................. 8

The dbDacFx Web Deploy provider ...................................................................................................... 8

Troubleshooting during this tutorial ......................................................................................................... 9

Comments welcome ................................................................................................................................. 9

Prerequisites ............................................................................................................................................. 9

Download the sample application .......................................................................................................... 10

Review application features that affect deployment ............................................................................. 13

Summary ................................................................................................................................................. 14

Preparing for Database Deployment .......................................................................................................... 15

Overview ................................................................................................................................................. 15

SQL Server Express LocalDB .................................................................................................................... 15

Entity Framework and Universal Providers ............................................................................................ 15

Configure Code First Migrations for application database deployment ................................................ 16

Disable the initializer ........................................................................................................................... 18

Enable Code First Migrations .............................................................................................................. 18

Set up the Seed method ..................................................................................................................... 20

Create scripts for membership database deployment ........................................................................... 23

Summary ................................................................................................................................................. 33

More Information ................................................................................................................................... 34

2

Web.config File Transformations ................................................................................................................ 35

Overview ................................................................................................................................................. 35

Web.config transformations versus Web Deploy parameters ............................................................... 35

Default transformation files .................................................................................................................... 35

Disable debug mode ............................................................................................................................... 36

Limit error log access to administrators ................................................................................................. 37

A setting that you'll handle in publish profile transformation files ........................................................ 42

Setting connection strings ...................................................................................................................... 43

Summary ................................................................................................................................................. 43

More Information ................................................................................................................................... 44

Project Properties ....................................................................................................................................... 45

Overview ................................................................................................................................................. 45

Configure deployment settings in the project properties window ........................................................ 45

Make sure that the Elmah folder gets deployed .................................................................................... 47

Summary ................................................................................................................................................. 48

Deploying to Test ........................................................................................................................................ 49

Overview ................................................................................................................................................. 49

Install IIS .................................................................................................................................................. 49

Install SQL Server Express ....................................................................................................................... 53

Create SQL Server Express databases for the test environment ............................................................ 53

Create a grant script for the new databases........................................................................................... 55

Run the grant script in the application database .................................................................................... 56

Publish to IIS ............................................................................................................................................ 57

Create the publish profile ................................................................................................................... 57

Configure deployment for the membership database ....................................................................... 61

Configure deployment for the application database .......................................................................... 62

Configure publish profile transforms .................................................................................................. 63

Preview the deployment updates ....................................................................................................... 64

Test in the test environment .................................................................................................................. 66

Review the automatic Web.config changes for Code First Migrations .................................................. 66

Summary ................................................................................................................................................. 67

More information ................................................................................................................................... 68

3

Setting Folder Permissions .......................................................................................................................... 69

Overview ................................................................................................................................................. 69

Test error logging and reporting ............................................................................................................. 69

Set write permission on the Elmah folder .............................................................................................. 70

Retest error logging and reporting ......................................................................................................... 71

Summary ................................................................................................................................................. 72

More information ................................................................................................................................... 72

Deploying to Production ............................................................................................................................. 73

Overview ................................................................................................................................................. 73

Get a Windows Azure account ................................................................................................................ 73

Create a staging environment ................................................................................................................. 73

Deploy the application to staging ........................................................................................................... 78

Download the .publishsettings file ..................................................................................................... 78

Create a publish profile ....................................................................................................................... 79

Configure a publish profile transform for the environment indicator ............................................... 84

Prevent public use of the test site ...................................................................................................... 85

Deploy to staging ................................................................................................................................ 86

Test in the staging environment ............................................................................................................. 86

Deploy to production .............................................................................................................................. 88

Create the production environment and the production publish profile .......................................... 88

Edit the .pubxml file to exclude robots.txt ......................................................................................... 88

Deploy to production .......................................................................................................................... 90

Summary ................................................................................................................................................. 91

Deploying a Code Update ........................................................................................................................... 93

Overview ................................................................................................................................................. 93

Make a code change ............................................................................................................................... 93

Deploy the code update to the test environment .................................................................................. 96

Take the application offline during deployment .................................................................................... 99

Create app_offline.htm ....................................................................................................................... 99

Copy app_offline.htm to the root folder of the web site ................................................................... 99

Deploy the code update to staging and production ............................................................................. 104

Reviewing Changes and Deploying Specific Files .................................................................................. 104

4

Make a change to deploy .................................................................................................................. 104

View the change in the Publish Preview window ............................................................................. 105

Publish specific files from Solution Explorer ..................................................................................... 107

Summary ............................................................................................................................................... 110

Deploying a Database Update .................................................................................................................. 112

Overview ............................................................................................................................................... 112

Deploy a database update by using Code First Migrations .................................................................. 112

Add a column to a table in the application database ....................................................................... 112

Display the new column in the Instructors page .............................................................................. 113

Deploy the database update ............................................................................................................. 115

Deploy a database update by using the dbDacFx provider .................................................................. 116

Add a column to a table in the membership database ..................................................................... 116

Create a page to display and edit the new column .......................................................................... 119

Deploy the database update ................................................................................................................. 120

Summary ............................................................................................................................................... 123

Command Line Deployment ..................................................................................................................... 126

Overview ............................................................................................................................................... 126

Make a change to deploy ...................................................................................................................... 126

Deploy to Test by using the command line........................................................................................... 128

Key command line options.................................................................................................................... 130

Deploying the solution versus deploying individual projects ........................................................... 130

Specifying the publish profile ............................................................................................................ 131

Web publish methods supported for command-line publishing ...................................................... 131

Specifying the build configuration and platform .............................................................................. 131

Deploy to staging .................................................................................................................................. 131

Deploy to production ............................................................................................................................ 132

Summary ............................................................................................................................................... 133

Deploying Extra Files ................................................................................................................................. 134

Overview ............................................................................................................................................... 134

Move the robots.txt file ........................................................................................................................ 134

ASP.NET Web Deployment using

Visual Studio

Tom Dykstra

Summary: This tutorial series shows you how to deploy (publish) an ASP.NET web application to a Windows Azure Web Site or a third-party hosting provider, by using Visual Studio 2012 or Visual Studio 2010. You develop a web application in order to make it available to people over the Internet. But web programming tutorials typically stop right after they've shown you how to get something working on your development computer. This tutorial begins where the others leave off: you've built a web site, tested it, and it's ready to go. What's next? This tutorial shows you how to deploy first to IIS on your local development computer for testing, and then to Windows Azure or a third- party hosting provider for staging and production. The sample application that you'll deploy is a web application project that uses the Entity Framework, SQL Server, and the ASP.NET membership system. The sample application uses ASP.NET Web Forms, but the procedures shown apply also to ASP.NET MVC and Web API.

Category: Step-by-Step

Applies to: ASP.NET, Visual Studio 2010, Visual Studio 2012, Windows Azure Source: ASP.NET Site (http://asp.net/web-forms/tutorials/deployment/visual-studio- web-deployment/introduction)

E-book publication date: April, 2013

Copyright © 2013 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.

7KLVERRNH[SUHVVHVWKHDXWKRU·VYLHZVDQGRSLQLRQV7KHLQIRUPDWLRQFRQWDLQHGLQWKLVERRNLVSURYLGHGwithout 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.

1

ASP.NET Web Deployment using Visual

Studio

Contents

Introduction .................................................................................................................................................. 6

Overview ................................................................................................................................................... 6

Intended audience .................................................................................................................................... 6

Using a third-party hosting provider ......................................................................................................... 7

Deploying web site projects ...................................................................................................................... 7

Deploying ASP.NET MVC projects ............................................................................................................. 7

Programming language ............................................................................................................................. 7

Database deployment methods................................................................................................................ 7

Entity Framework Code First Migrations .............................................................................................. 8

The dbDacFx Web Deploy provider ...................................................................................................... 8

Troubleshooting during this tutorial ......................................................................................................... 9

Comments welcome ................................................................................................................................. 9

Prerequisites ............................................................................................................................................. 9

Download the sample application .......................................................................................................... 10

Review application features that affect deployment ............................................................................. 13

Summary ................................................................................................................................................. 14

Preparing for Database Deployment .......................................................................................................... 15

Overview ................................................................................................................................................. 15

SQL Server Express LocalDB .................................................................................................................... 15

Entity Framework and Universal Providers ............................................................................................ 15

Configure Code First Migrations for application database deployment ................................................ 16

Disable the initializer ........................................................................................................................... 18

Enable Code First Migrations .............................................................................................................. 18

Set up the Seed method ..................................................................................................................... 20

Create scripts for membership database deployment ........................................................................... 23

Summary ................................................................................................................................................. 33

More Information ................................................................................................................................... 34

2

Web.config File Transformations ................................................................................................................ 35

Overview ................................................................................................................................................. 35

Web.config transformations versus Web Deploy parameters ............................................................... 35

Default transformation files .................................................................................................................... 35

Disable debug mode ............................................................................................................................... 36

Limit error log access to administrators ................................................................................................. 37

A setting that you'll handle in publish profile transformation files ........................................................ 42

Setting connection strings ...................................................................................................................... 43

Summary ................................................................................................................................................. 43

More Information ................................................................................................................................... 44

Project Properties ....................................................................................................................................... 45

Overview ................................................................................................................................................. 45

Configure deployment settings in the project properties window ........................................................ 45

Make sure that the Elmah folder gets deployed .................................................................................... 47

Summary ................................................................................................................................................. 48

Deploying to Test ........................................................................................................................................ 49

Overview ................................................................................................................................................. 49

Install IIS .................................................................................................................................................. 49

Install SQL Server Express ....................................................................................................................... 53

Create SQL Server Express databases for the test environment ............................................................ 53

Create a grant script for the new databases........................................................................................... 55

Run the grant script in the application database .................................................................................... 56

Publish to IIS ............................................................................................................................................ 57

Create the publish profile ................................................................................................................... 57

Configure deployment for the membership database ....................................................................... 61

Configure deployment for the application database .......................................................................... 62

Configure publish profile transforms .................................................................................................. 63

Preview the deployment updates ....................................................................................................... 64

Test in the test environment .................................................................................................................. 66

Review the automatic Web.config changes for Code First Migrations .................................................. 66

Summary ................................................................................................................................................. 67

More information ................................................................................................................................... 68

3

Setting Folder Permissions .......................................................................................................................... 69

Overview ................................................................................................................................................. 69

Test error logging and reporting ............................................................................................................. 69

Set write permission on the Elmah folder .............................................................................................. 70

Retest error logging and reporting ......................................................................................................... 71

Summary ................................................................................................................................................. 72

More information ................................................................................................................................... 72

Deploying to Production ............................................................................................................................. 73

Overview ................................................................................................................................................. 73

Get a Windows Azure account ................................................................................................................ 73

Create a staging environment ................................................................................................................. 73

Deploy the application to staging ........................................................................................................... 78

Download the .publishsettings file ..................................................................................................... 78

Create a publish profile ....................................................................................................................... 79

Configure a publish profile transform for the environment indicator ............................................... 84

Prevent public use of the test site ...................................................................................................... 85

Deploy to staging ................................................................................................................................ 86

Test in the staging environment ............................................................................................................. 86

Deploy to production .............................................................................................................................. 88

Create the production environment and the production publish profile .......................................... 88

Edit the .pubxml file to exclude robots.txt ......................................................................................... 88

Deploy to production .......................................................................................................................... 90

Summary ................................................................................................................................................. 91

Deploying a Code Update ........................................................................................................................... 93

Overview ................................................................................................................................................. 93

Make a code change ............................................................................................................................... 93

Deploy the code update to the test environment .................................................................................. 96

Take the application offline during deployment .................................................................................... 99

Create app_offline.htm ....................................................................................................................... 99

Copy app_offline.htm to the root folder of the web site ................................................................... 99

Deploy the code update to staging and production ............................................................................. 104

Reviewing Changes and Deploying Specific Files .................................................................................. 104

4

Make a change to deploy .................................................................................................................. 104

View the change in the Publish Preview window ............................................................................. 105

Publish specific files from Solution Explorer ..................................................................................... 107

Summary ............................................................................................................................................... 110

Deploying a Database Update .................................................................................................................. 112

Overview ............................................................................................................................................... 112

Deploy a database update by using Code First Migrations .................................................................. 112

Add a column to a table in the application database ....................................................................... 112

Display the new column in the Instructors page .............................................................................. 113

Deploy the database update ............................................................................................................. 115

Deploy a database update by using the dbDacFx provider .................................................................. 116

Add a column to a table in the membership database ..................................................................... 116

Create a page to display and edit the new column .......................................................................... 119

Deploy the database update ................................................................................................................. 120

Summary ............................................................................................................................................... 123

Command Line Deployment ..................................................................................................................... 126

Overview ............................................................................................................................................... 126

Make a change to deploy ...................................................................................................................... 126

Deploy to Test by using the command line........................................................................................... 128

Key command line options.................................................................................................................... 130

Deploying the solution versus deploying individual projects ........................................................... 130

Specifying the publish profile ............................................................................................................ 131

Web publish methods supported for command-line publishing ...................................................... 131

Specifying the build configuration and platform .............................................................................. 131

Deploy to staging .................................................................................................................................. 131

Deploy to production ............................................................................................................................ 132

Summary ............................................................................................................................................... 133

Deploying Extra Files ................................................................................................................................. 134

Overview ............................................................................................................................................... 134

Move the robots.txt file ........................................................................................................................ 134