How to read from web.config?

R

RA

Hi

I want to read information from the web.config in my asp.net (c#), how can I
do it? I want to read from there the sql connection string.


Thanks
 
G

Gerald

You have to import System.Configuration

Lets say you have this in your web.config file:
<appSettings>
<add key="keyName" value="keyValue" />
</appSettings>

Retrieve it like this

using System.Configuration;

ConfigurationSettings.AppSettings["keyName"];

Gerald

Then you retriev it like
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top