Environment variables are a great thing for when you publish your website to multiple places. It doesn't matter if you publish it to testing / staging / production environment or if you're publishing your site to several servers which require different methods to be called / different values assigned to parameters.

Let's create a web application project:

1. Open Visual Studio 2010
2. Create New Project -> ASP.NET Web Application

As you can see, you automatically have two configuration options:
- Debug
- Release

3. Right click on the project in the Solution Explorer. Click on Properties and click on Build tab.

4. Under that tab you have many configuration options. The field we're interested in is "Conditional compilation symbols". While on Debug mode, we will write a variable name in this field. Example: "vDebug"

5. After saving, you will have an identifier for when in Debug mode.
6. Before testing our work, we're gonna create another Configuration. Click on the configuration drop down list and choose Configuration Manager

7. Add new Configuration - TestRelease:


8. Now place the variables in Release Configuration and in TestRelease Configuration. I've placed the variables: vRelease and vTestRelease
9. Now for the test. Create a similar code on your Default.aspx.cs page:

When you will run the code, you'll see that for each configuration option it will it the correct method.