What is the best way to read values from the web.config file.
I know how to read from the appSettings section, I want to read from other
sections like those listed below.
Thanks,
TPS
<customErrors mode="Off" defaultRedirect ="/Pages/customerror.asp x"/>
<authenticati on mode="Forms">
<forms
slidingExpirati on="true"
loginUrl="/pages/login.aspx"
name="dusacooki e"
timeout="60"
path="/">
</forms>
</authentication>
<trace
enabled="false"
requestLimit="1 0"
pageOutput="tru e"
traceMode="Sort ByTime"
localOnly="true "
/> 3 2455
You can create your own sections via configurationHa ndlers, you can read up
on this at: http://openmymind.net/Configuration/index.html
However, I think what you are saying is you want to read the application
values from the web.config. A lot of those are read into objects you can
access. For example you can type Page.Trace.Trac eMode to get the mode
specified in web.config
You can use Session.Session Mode/TimeOut
You can also get some from Context.IsCusto mErrorEnabled
As you can see, they are read into a veriaty of objects...and I'm not sure
all the information is available. You might need to simply read it as an
XML document and parse it....
Not sure why you'd want this information anyways..
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"TPS" <tp*@tps.com> wrote in message
news:uz******** ******@tk2msftn gp13.phx.gbl... What is the best way to read values from the web.config file.
I know how to read from the appSettings section, I want to read from other sections like those listed below.
Thanks, TPS <customErrors mode="Off" defaultRedirect ="/Pages/customerror.asp x"/>
<authenticati on mode="Forms">
<forms
slidingExpirati on="true"
loginUrl="/pages/login.aspx"
name="dusacooki e"
timeout="60"
path="/">
</forms>
</authentication> <trace
enabled="false"
requestLimit="1 0"
pageOutput="tru e"
traceMode="Sort ByTime"
localOnly="true "
/>
Thanks for Karl's good suggestions.
Hi TPS,
As for reading the settings in the web.conrfig I think Karl's suggestions
are quite reasonable. Also, there may be some scenarios that we can't read
web.config via those means, for example , in design-time .., then I think
we can just load the web.config as a normal xmlDocument and use the DOM
collection to retrieve any elements we want. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Thanks for both of your suggestions
TPS
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:a8******** ******@cpmsftng xa06.phx.gbl... Thanks for Karl's good suggestions.
Hi TPS,
As for reading the settings in the web.conrfig I think Karl's suggestions are quite reasonable. Also, there may be some scenarios that we can't read web.config via those means, for example , in design-time .., then I think we can just load the web.config as a normal xmlDocument and use the DOM collection to retrieve any elements we want. Thanks.
Regards,
Steven Cheng Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Get Preview at ASP.NET whidbey http://msdn.microsoft.com/asp.net/whidbey/default.aspx This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sami |
last post by:
Hello, I have this problem that I need your help with : I am reading a
config file that contain the following :
2004
update
|
by: spacekid |
last post by:
Hi there
I am exposing a c# assembly as a COM component (regasm /codebase) and
calling it from classic asp. When I try to call the
ConfigurationSettings.AppSettings function in the c# assembly, it does
not return the values from my web.config.
The web.config is located in the root of the web application. The
classic asp page that calls the COM exposed c# assembly is located in a
subfolder called message. Can anyone help me out here?
|
by: news.microsoft.com |
last post by:
Hi
After conducting a several searches, I wasn't sure where to post this
question. So my apologiesbefore hand for double posting this and possibly
posting to the wrong forum(s).
Okay, I have any application that uses the data access application building
block from Microsoft's Enterprise Library (patterns and practices site). I
want to allow the users to select the database connection. To do this, I
thought I could read the...
|
by: comic_rage |
last post by:
Hi,
I am trying to read from my application config file and keep getting
null.
Here is my config file
My application is called SampleApp.exe
|
by: Ryan |
last post by:
I've created a custom configuration section that inherits (naturally) from
System.Configuration.ConfigurationSection. The configuration section is
working 99% fine, however I keep coming across a ConfigurationErrorException
whenever I do the following:
1. Modify and save the section in code using the
System.Configuration.Configuration.Save().
2. Refresh teh section using ConfigurationManager.RefreshSection
3. Encrypt the section,...
| |
by: marek zegarek |
last post by:
Hello!
On my server I have Sharepoint portal server as default web site
I create there a web application folder with form.aspx file.
When I'm trying to run aspx, i get an error.
Page is trying to read config from x:\inetpub\wwwroot\web.config.
Correct path is x:\inetpub\wwwroot\test\web.config.
How to force on application (or IIS or whatever) to use correct config?
|
by: alf |
last post by:
Hi folks,
I'm trying to read a web.config section using
RoleManagerSection settings =
(RoleManagerSection)System.Configuration.ConfigurationManager.GetSection("system.web/roleManager");
and I get the following error on the page:
Security Exception
Description: The application attempted to perform an operation not allowed
|
by: Milsnips |
last post by:
Hi all.
i'm tryng to implement the Rewrite.NET url rewritining functionality into a
test project i've created, however i am hitting a problem at this line
(direct from the web example):
System.Collections.Specialized.NameValueCollection SectionIndex =
(System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationSettings.GetConfig("Rewrite.NET/Index");
The value always returns me null, and just to check it was...
|
by: M Irfan |
last post by:
Hello all,
Recently I have started working in .NET 2.0. I am developing a web
service application that references a DLL component written in C# 2.0.
The component has its own config file which contains settings related
to business logic coded in that component. I can reference and load
the component but unable to read load the custom config file of that
component. I know that the same thing is possible if my host
application is any Exe...
|
by: vijayarl |
last post by:
Hi Everyone,
i have the written this logic :
basically a file operation
open (CONFIGFILE, "$config_file") or die;
while (<CONFIGFILE>) {
chomp;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |