Key value pair in web.config file and using it in cs page using C#

Banaglore: Asp.net configurationmanager library provides the feature to keep the commonly used or custom values in web.config/app.config as key value pair.
so users can call that values wherever they want in the application.

<configuration>
   <appSettings>
        <add key="test" value="testvalue"/>
        <add key ="test1" value="testvalue1"/>
    </appSettings>
</configuration>


So we have given our code inside the web.config file now we are going to use it in our cs file.

 string testvalue= System.Configuration.ConfigurationManager.AppSettings["test"];
 string testvalue1= System.Configuration.ConfigurationManager.AppSettings["test1"];
So Inside AppSettings you have to give the key you have given in the web.config. so here test and test1 in our case.


/* androidsharp */

0 comments: