Global Web.Config Settings
Category: DotNet
Placing certain configuration global variables in the web.config can be very useful. It can save you having to re-deploy your application to production, which can in some scenarios be a scary thing. It also gives you a centralized place for keeping track of important constant variables, which you can access from anywhere in your app
To extract the variable it depends on where in the structure of your site it is located. If you simply have an app with one web.config, it is quite simple and Intellisense helps you our. If you have multiple apps within an app, and the app setting you want is in the website root web.config, use the second method below.
// standard method string connectString = myproject.Properties.Settings.Default.SettingsConnectionString; // website root web.config connectString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
To place the Global setting in your project visually, simply: Right Click on the Properties Folder at the top of your Project and choose Open. Click the "Settings" tab on the left, and you will see the application settings listed.
To place the settings manually, edit your Web.config and add the following code, editing for your needs.
SQL SERVER: blah/blah etc USEMIRROR=true