Creating custom variable in web.config file?

Chakri picture Chakri · Mar 7, 2014 · Viewed 29.7k times · Source

I want to create a variable in web.config file and to use that variable in web forms. How can I achieve this??

Answer

DmitryK picture DmitryK · Mar 7, 2014

in web.config:

<appSettings>
   <add key="message" value="Hello, World!" />
</appSettings> 

in cs:

string str = ConfigurationManager.AppSettings["message"].ToString();