18.1. Preparing Your Web Site for Deployment

When you're working on the first edition of your web site in a development environment, managing the site and its source code is pretty straightforward. You only have a single version of the site's source, making it easy to maintain. However, as soon as you put your site in production, you now have two versions of the site: one running in the production environment and the one you use for development. This makes it difficult to keep things synchronized. For example, you probably use a different database and connection string in your production environment. You're also likely to use different e-mail addresses for the e-mail that is sent by the site. Finally, you may want to disable sending the error e-mails from the Global.asax files in a development environment. If you make all of these changes in the code directly when you put your site live, there's a fair chance that you'll overwrite some settings during the next update, which can lead to unwanted results.

This section shows you how to make managing different versions of the same web site a little easier. You see how to move some of the hardcoded settings, like e-mail addresses, to the web.config file. The code in your application then reads these values at run time. The only difference between your development and production environments is a single configuration file, making it easy to have different settings in both environments.

18.1.1. Avoiding Hardcoded Settings

So far the ...

Get Beginning ASP.NET 3.5: In C# and VB now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.