473,322 Members | 1,501 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,322 software developers and data experts.

How to add and retrieve value from web.config file

4
I want to have in web.config file any tag contains the value: low/meduim/high which I can change by my decision,

In my class I want to check the value of the tag and according the value to send message,

my questions: in which tag should I put it? where to place the tag in web.config file ?
and how can I check in my class what the tag contains?

it's very urgent for me,
thanks in advance!
TW
Sep 13 '11 #1

✓ answered by Frinavale

You should add an element to the <appSettings> section of your web.config file.

Like this:
Expand|Select|Wrap|Line Numbers
  1. <appSettings>
  2.   <add key="loggingLevel" value="medium" />
  3.   <!-- other settings -->
  4. </appSettings>
  5.  
Then in your class implementation you can retrieve the value using the ConfigurationManager. Like this:
(C#)
Expand|Select|Wrap|Line Numbers
  1. string loggingLevel = System.Configuration.ConfigurationManager.AppSettings["loggingLevel"].value;
(VB.NET)
Expand|Select|Wrap|Line Numbers
  1. Dim loggingLevel As String = System.Configuration.ConfigurationManager.AppSettings("loggingLevel").value
-Frinny

2 1989
Frinavale
9,735 Expert Mod 8TB
You should add an element to the <appSettings> section of your web.config file.

Like this:
Expand|Select|Wrap|Line Numbers
  1. <appSettings>
  2.   <add key="loggingLevel" value="medium" />
  3.   <!-- other settings -->
  4. </appSettings>
  5.  
Then in your class implementation you can retrieve the value using the ConfigurationManager. Like this:
(C#)
Expand|Select|Wrap|Line Numbers
  1. string loggingLevel = System.Configuration.ConfigurationManager.AppSettings["loggingLevel"].value;
(VB.NET)
Expand|Select|Wrap|Line Numbers
  1. Dim loggingLevel As String = System.Configuration.ConfigurationManager.AppSettings("loggingLevel").value
-Frinny
Sep 13 '11 #2
TWTW
4
@Frinavale
thanks a lot!, it work's!
Sep 16 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply*...
1
by: José Joye | last post by:
Hello, I have an assembly that is used by a VB6 application. This application can be a normal exe or an ActiveX (called through CCW). My assembly needs to get extra info from a config file. In...
6
by: Ajay Pal Singh | last post by:
Hi, I am creating a web service, which needs to take some actions based on the config file. I need a way to listen the changes as they occur in the config file so that the service can take...
3
by: Charlie | last post by:
Hi: I created a config file to retrieve DSN at runtime from a C# library project (DLL). I name the file same as DLL (libRADIUS.config). Here is the contents of the file... <?xml...
3
by: Henry | last post by:
Hi, my asp.net application is accessing a mssql on another server. This works fine when I use this in my web.config file: <add key="dbkey"...
6
by: Rich | last post by:
Hello, I picked up this example on using the Reflection namespace for loading forms/classes on the fly at msdn http://msdn.microsoft.com/library/default.asp?...
4
by: Jeff smith | last post by:
I am reading the value from config file using the below statement. System.Configuration.ConfigurationSettings.AppSettings("MY_DATA") How to write data back to the same location? I am using...
3
by: Blasting Cap | last post by:
I am working on a web app that I want to be able to use a separate config file on, in addition to the web.config file that's already working in the application. If I put the following in the...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
5
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.