i already have a phpcode with hard coded values,
$username = "abcd";
$password = "abcd123";
now i wanted to put those values to web.config file.here is my work,but something wrong here.
<appSettings>
<add key="username" username="abcd"/>
<add key="password" password="abcd123"/>
<appSettings/>
so.. is there any problem ? and i also wanted to know how can i take this settings to aspx.cs file.. i mean [configurationmanager] something
You need to declare them with the key and value properties instead, like so:
If you want the basics, you can access the keys via:
To access my web config keys I always make a static class in my application. It means I can access them wherever I require and I’m not using the strings all over my application (if it changes in the web config I’d have to go through all the occurrences changing them). Here’s a sample: