How to read from web.config?

  • Thread starter Thread starter RA
  • Start date Start date
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
 
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
 
Back
Top