Here is a concise definition for a web.config file from wikipedia.
Source: wikipedia
“The web.config is the main settings and configuration file for an ASP.NET web application. The file is a text based XML document that defines such things as connection strings to any databases the application uses, the default language for child pages, whether debugging is allowed and how it can be implemented, whether session state is used by default, what type of authentication is used, if any, and so on.
Web.config files can only be placed inside directories that have been configured as ASP.NET applications, commonly the web application's root directory. Web.config files inherit properties from higher level .config files and ultimately machine.config however some settings inside machine.config cannot be overridden.
The web.config file is so central to the ASP.NET framework that when the file is saved, IIS restarts the application it belongs to. Visual Studio will automatically create a web.config file when needed, such as compiling a web application to run in debug mode.”
Our web application will be mainly using the web.config for storing the default login credentials for an Administrator user, the dispatcher value and the includes folder for any JavaScript or images.
<appSettings>
<add key="CTSpwd" value="admin1234" />
<add key="CTSuid" value="administrator" />
<add key="CNmspace" value="1101" />
<add key="CCurl" value="http://server/cognos8/cgi-bin/cognosisapi.dll?b_action=xts.run&m=portal/cc.xts&CAMUsername=CC_UID&CAMPassword=CC_PWD&h_CAM_action=logonAs&CAMNamespace=CC_NM" />
<add key="CognosSDKPathIncludes" value="http://server/cognos8/" />
<add key="CognosDispatcher" value= "http://server:9300/p2pd/servlet/dispatch" />
<add key="CSTypePkg" value="packageConfiguration" />
<add key="CSTypeRpt" value="report" />
</appSettings>
The C# code uses the following syntax to retrieve the value stored in the web.config.
_dispC8 = ConfigurationSettings.AppSettings["CognosDispatcher"];
You can see that this value corresponds to the web.config setting.
<add key="CognosDispatcher" value= "http://MyServerName:9300/p2pd/servlet/dispatch" />