Configuration and Environment Variables - Visual Studio 2010
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.
Lets create a web application project (further explanations will be granted later)
- Open Visual Studio 2010
- Create New Project -> ASP.NET Web Application
As you can see, you automatically have two configuration options:
Click on Properties.
Click on Build tab.
Under that tab you have many configuration options (which will be discussed in another post).
The field we're interested in is "Conditional compilation symbols".
While on Debug mode, we will write a variable name in this field.
Before testing our work, we're gonna create another Configuration.
Click on the configuration drop down list and choose Configuration Manager
Add new Configuration - TestRelease:
Now place the variables in Release Configuration and in TestRelease Configuration.
I've placed the variables: vRelease and vTestRelease
Now for the test.
Create a similar code on your Default.aspx.cs page:
Hope it helped,
CTO at ITweetLive.com