What is the appSettings section in the web.config file?

Asked 07-Dec-2019
Viewed 789 times

1 Answer


0

AppSettings section in the Web.config file

Web.config file defines configuration for a webproject.

AppSetting section is used to set the user defined values.

For e.g.: The ConnectionString which is used through out the project for database connection.

<configuration>

<appSettings><BR><addkey="ConnectionString"value="server=xyz;pwd=www;database=testing" />
</appSettings>

And Other is - 

The AppSetting section in the configuration file is a section that allows us to keep configurable and application wide settings (For example : ConnectionString) that an application requires in order to perform the tasks properly. This helps in easy maintenance and deployment of the application.

Web.confg:

<appsettings>

    <add key="ConnectionString" value="(your connection string)" />
</appsettings>

Code behind: 

string strConnection = ConfigurationSettings.AppSettings["ConnectionString"];