473,378 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to read from web.config?

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
Nov 18 '05 #1
1 992
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
"RA" <ro****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Karthikesh Raju | last post by:
Hi All, i am wondering about the best way to read in a configuration file that goes like: ########### source_dir = '/home/karthik/Projects/python' data_dir =...
2
by: MrFile | last post by:
I added an app.config file to my application. (c#.net component dll) <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="username" value="xx" /> <add...
3
by: Mustaq | last post by:
Hi, How to read same config file from different application? I have 4 application in VB.NET, all are using different app.config files. NOW I need all to read only one config file, how can I do...
1
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
4
by: Chris V | last post by:
I'm having a problem deploying my ASP.NET application to a WIN2k server. (IIS5 .NET 1.1) When I try to access ConfigurationSettings.AppSettings("WhateverValue") I get an "Object reference not...
4
by: brent | last post by:
Currently our application is reading from the web.config, and retrieves a section, "softwareRequirements". Because the section will begin to grow dramatically, I'd like to place it in the SQL...
10
by: NuB | last post by:
I'm creating a C# class file(DLL) that will be used by an asp.net application. In the DLL I want to read a web.config, or app.config file so some information can change without having to go into...
5
by: Sridhar | last post by:
Hi, I have created a project which contains classes to read the data from the database. This project has an App.Config file which contains the SqlConnection String. when this code is called from...
3
by: Brett Romero | last post by:
I'd like to use some of the techniques discussed here for reading a config file in .NET 2.0: http://msdn.microsoft.com/msdnmag/issues/06/06/ConfigureThis/default.aspx Here's my app.config...
9
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.