Web.Config is IMHO, a terrible place to store this kind of configuration information - it's hard to deploy and hard to change, especially if you use multiple web interfaces.
The recommended way to do this is to use the PropertyBag (key / value pairs) through .Properties SPFarm, SPWeb.RootWeb (for site collections), SPWeb, SPList, etc. (depending on the area you need).
MSDN - Manage Customizing Settings for a SharePoint Application
There is a ready-made production code that is available as part of
MSDN - SharePoint Guide Library
See Hierarchical Configuration Manager
This gives you programmatic read / write access to these values. If you want to do this without using the instruction library, you should use something like the following code.
SPWeb web = SPContext.Current.Web; if (web.Properties.ContainsKey("MyProperty")) string myProperty = web.Properties["MyProperty"];
If you want the user interface to allow administrators to easily set values, use something like the SharePoint Property Pack Settings
source share